Selection Actions

A contextual AI action bar that appears beneath selected text — explain, improve, shorten, fix grammar, or a custom edit.

Default

Highlight a selection, then Explain / Improve / expand / custom prompt. Demo runs idle → thinking → result once per action.

Loading…

Installation

CLI
npx @sonojs/ui@latest add selection-actions
Also needsnpm i lucide-react motion

Usage

selection-actions.tsx
import { SelectionActions } from "@/components/sonojs/selection-actions"

export function Example() {
  return (
    <SelectionActions
      leadingText="Pistachio holds the top slot all weekend. "
      selection="Churn it first thing Saturday…"
      result="Churn pistachio first thing Saturday…"
    />
  )
}

Props

PropTypeDefaultDescription
leadingTextstringsample lead-inText preceding the highlighted selection.
selectionstringsample selectionHighlighted text the actions operate on.
resultstringsample resultReplacement text after a successful action.
classNamestring—Merge classes on the root.