Skip to content
Viewership Inquire
Astro UI

Selection Actions.

Select text and a floating toolbar rewrites it in place.

AgentComponent3 dependencies Beautiful UI, MIT

.md

The trail pack page gets most AI citations. Keep it in this week's client report. Update it first thing Friday so the copy has a full day for review before the weekend launch.

Select text, or use the arrow keys to choose a sentence (Shift extends), then press Tab to reach the edit toolbar.

Install

  1. Import the foundation once

    foundation.css holds the tokens every component reads.

    Layout.astro
    ---
    // src/layouts/Layout.astro
    import "../styles/foundation.css";
    ---
  2. Copy SelectionActions.astro

    Paste into src/components/viewership/selection-actions/

  3. Copy its dependencies

    Each in its own folder, next to this one.

  4. Use it

    Page.astro
    ---
    import SelectionActions from "../components/viewership/selection-actions/SelectionActions.astro";
    ---
    
    <SelectionActions />

Props 6

PropTypeDefaultDescription
passage { text, rewrites?, rewrite? }[] · Segments (usually sentences). Selection snaps to them. `rewrites` is keyed by action or "custom"; `rewrite` is the fallback.
selected number | [number, number] 0 Initial segment or inclusive range.
actions { primary: SelectionAction[]; more: SelectionAction[] } Explain, Improve · Shorten, Tone, Grammar { id, icon?, action?, busyLabel? }. Omit `action` for non-rewrite actions.
labels { keep?, discard?, placeholder?, toolbar? } · UI and aria text.
autoShow boolean true Show the toolbar once in view.
Events CustomEvent · vs-selection-action { action, prompt?, text, rewrite, respondWith(text | Promise) }, vs-selection-keep { original, text }, vs-selection-discard { original }.

Source 1 file

Ported from Beautiful UI, MIT. Notices.