Selection actions
ProSelect text inside a reply and act on just that part: ask a follow-up about it, have it explained, or quote it into the composer. The toolbar appears above the selection and only for selections inside this container; Escape or clicking away dismisses it.
Preview
Install
With the Candor CLI
First time? Get started sets up the registry and theme. Or with shadcn directly: npx shadcn@latest add @candor/selection-actions
Brings in: locale, utils · npm: lucide-react@^1.67.0
Usage
"use client"
import * as React from "react"
import { SelectionActions, type SelectionAction } from "@/components/selection-actions"
export default function Example() {
const [last, setLast] = React.useState<{ action: SelectionAction; text: string } | null>(null)
return (
<div className="flex max-w-lg flex-col gap-3">
<SelectionActions onAction={(action, text) => setLast({ action, text })}>
<p className="text-sm leading-relaxed">
The checkout flag is on in Staging but off in Production. Turning it on adds a write to the payments table on every order, so watch the
replication lag for the first hour.
</p>
</SelectionActions>
<p className="text-xs text-muted-foreground">
{last ? `${last.action}: “${last.text}”` : "Select some of the text above to act on it."}
</p>
</div>
)
}<SelectionActions>
| Prop | Type | Default | Description |
|---|---|---|---|
| onActionrequired | (action: SelectionAction, text: string) => void | — | Called with the action picked and the selected text. |
| childrenrequired | React.ReactNode | — | What goes inside. |
| className | string | undefined | — | Extra classes for the outer element. |
Strings
The fixed words, in English by default. Change any of them under selectionActions in <LocaleProvider strings={{ … }}>; the table is exported as selectionActionsStrings.
| Key | English |
|---|---|
| ask | Ask about this |
| explain | Explain |
| quote | Quote |
| toolbar | Selected text |
Types
- SelectionAction
"ask" | "explain" | "quote"