Selection Toolbar
ProA floating row of actions over text the reader selects — quote it, ask about it, explain it — with a keyboard path for read-only text.
</>sv-selection-toolbar aichatselectiontoolbarquote
import { SvSelectionToolbarComponent } from '@styloviz-pro/ai-chat';Demo & usage
Basic usage
Usage example — open the gallery for the full interactive demo.
Pro
An interactive demo for this component lives in the gallery.
Open live demoMore examples
Quote into the composer
When to use
A follow-up that starts from part of an answer: quote it, ask about it, explain it. Any read-only text the user acts on a phrase at a time. For rewriting text the user is editing, use the AI Writing Assistant.
Async states
None — this component has nothing to load, so it has no loading, empty or error state to drive.
Inputs
| Name | Type | Default | Description |
|---|---|---|---|
| actions | readonly SvSelectionAction[] | [] | The actions to offer. Empty turns the toolbar off. |
| minLength | number | 1 | Shortest selection, in characters, that opens the toolbar. |
| disabled | boolean | false | Stop offering the toolbar. |
| ariaLabel | string | null | null | The toolbar's accessible name; `null` uses the `selectionActions` label. |
| labels | Partial<SvAiChatProLabels> | {} | Per-instance text, merged over the registry's `aiChatPro` labels. |
Outputs
| Event | Payload type | Description |
|---|---|---|
| action | SvSelectionActionEvent | An action was pressed over a selection. The toolbar closes. |
Customization & theming
`(action)` carries `{ action, text, block }`; the toolbar closes afterwards. The host is an inline element: give it `block`, or `contents` to stay out of a flex or grid layout. Portalled to `<body>`, centred above the selection and flipped below when there is no room; it closes when the selection collapses, the block scrolls away or the press lands outside. In `sv-ai-chat`, bind `[selectionActions]`; an action with id `quote` also quotes the selection into the composer.
Best practices
Do: Mark each block with `data-sv-selection-block` and `tabindex="0"`. Read-only text is not keyboard-selectable, so Enter on a focused block is the keyboard path — and the event tells you which block it was. Do: Keep it to two to four actions; the toolbar sits over the text the reader is looking at. Don't: Do not open it on every click — `[minLength]` ignores accidental one-character selections.
Accessibility
`role="toolbar"` with a name; arrow keys move between its buttons and Escape returns focus to the block it opened from. Focus follows the keyboard into the toolbar, and only the keyboard — a mouse selection keeps the caret where it was. Touch needs nothing extra: a long-press selection opens it the same way.
Feedback on Selection Toolbar
Spotted a gap in this page, or something that didn't work as described? Comments are GitHub Discussions in the public styloviz/community repo, so posting needs a GitHub account.