Updated
Selection Toolbar
ProCustomize
Duration0.32s
Offset8px
Installation
ProSelection Toolbar is a Pro component
Sign in to see the source, or install it with a license key. The live preview and props above are free to explore.
Buying? Use the email you'll sign in with. Your license is tied to it.
Install with a key
- Add the Pro registry to
components.json:components.json { "registries": { "@uibrik-pro": { "url": "https://uibrik.com/r/pro/{name}.json", "headers": { "Authorization": "Bearer ${UIBRIK_LICENSE}" } } } } - Put your key in
.env.localand add that file to.gitignore:.env.local UIBRIK_LICENSE=your-license-key - Install it:
Terminal npx shadcn@latest add @uibrik-pro/selection-toolbar
Loading your installation…
Usage
import { SelectionToolbar } from "@/components/uibrik/selection-toolbar/selection-toolbar";const actions = [ { id: "bold", label: "Bold", icon: <IconBold stroke={2.5} /> }, { id: "italic", label: "Italic", icon: <IconItalic stroke={2.5} /> }, // …3 more];<SelectionToolbar duration={0.32} offset={8} actions={actions} peek onAction={(id, { text, range, value }) => {}} onRemove={(el) => {}} // isActive={(id) => {}}> …</SelectionToolbar>Where to use Selection Toolbar
Rich text editors
Bold, italic and links sit right above the words they change.
Pairs with Gliding Tooltip
Comments on documents
Select a passage and comment on it without leaving the text.
Pairs with Pin Comment
Reading tools
Highlight, share or ask about a quote straight from the selection.
Props
SelectionToolbar- duration
- Type number
- 0.32
- Sets the pace: how long the pill takes to rise in, follow the selection and change width.
- offset
- Type number
- 8
- Gap between the selection and the pill.
- actions
- Type SelectionAction[]
- –
- Each has an id, label and icon. Give one an input ({ placeholder }) and the pill turns into a field for it.
- onAction
- Type (id, { text, range, value }) => void
- –
- Runs an action on the selection, which is restored first. value holds what was typed, for actions with an input.
- peek
- Type boolean
- true
- Preview links (a[href]) and comments ([data-comment]) on hover or when the caret is in one, with Open and Remove.
- onRemove
- Type (el) => void
- –
- Removes a previewed link or comment. Leave out to unwrap it in place, for contentEditable text.
- isActive
- Type (id) => boolean
- –
- Marks an action as on for the current selection, e.g. bold.
- children
- Type ReactNode
- –
- The content people select text in: text, or a contentEditable region.
- className
- Type string
- –
- Classes for the region.