Selection Toolbar
A toolbar that appears over the text a reader selects: Ask AI, Comment, Bold, or any action the app slots in.
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
placement | 'top' | 'bottom' | top | Where the toolbar sits: above the selection, or below it. It flips when there is no room. |
min-length | number | 1 | The fewest characters, once trimmed, a selection needs for the toolbar to show. |
disabled | boolean | false | Never shows the toolbar. |
label | string | — | The toolbar's accessible name. |
Slots
| Name | Description |
|---|---|
(default) | The content whose selections the toolbar acts on. |
toolbar | The toolbar's controls: c2-button, c2-icon-button or any focusable element. Give one data-action to have it fire selection-action. |
Events
| Name | Type | Description |
|---|---|---|
selection-change | CustomEvent<{ text: string }> | Fired when the toolbar shows for a selection or its selection changes. Does not bubble. |
toggle | CustomEvent<{ open: boolean }> | Fired when the toolbar opens or closes. |
selection-action | CustomEvent<{ action: string; text: string }> | Fired when a toolbar control with data-action is pressed, with the action and the selected text. |
CSS parts
Shadow DOM styling hooks used with ::part(name). Prefer CSS custom properties when they cover the change.
| Name | Description |
|---|---|
toolbar | The floating toolbar. |
CSS custom properties
Grouped by semantic target and state from --c2-<component>__<target>__<state>--<property>. Click a group to collapse it; click a name to copy it.
| Name | Type | Default | Description |
|---|---|---|---|
--c2-selection-toolbar--background | color | #ffffff | |
--c2-selection-toolbar--border | border | 1px solid #e4e4e7 | |
--c2-selection-toolbar--border-radius | border-radius | 8px | |
--c2-selection-toolbar--box-shadow | shadow | 0 4px 12px rgba(0, 0, 0, 0.12) | |
--c2-selection-toolbar--padding | padding | 4px | |
--c2-selection-toolbar--gap | pixel | 2px | Space between the controls. |
--c2-selection-toolbar--offset | pixel | 8px | Distance from the selection. |
Text and languages
The text the component shows, in English. It shows another language when the app adds one with addTranslations, under selection-toolbar, and the nearest lang asks for it; any message not translated stays in English. {0}, {1}… stand for the values a message carries. Languages guide.
| Key | English | Values |
|---|---|---|
label | Selection actions | — |
hint | Actions available, press Alt+F10 | — |