YuhuanStudioYunUIDocs
AI

SelectionActions

The host supplies the selected passage, edit state and result. The toolbar anchors to that passage; actions and custom instructions only request work. Keep/Discard callbacks leave persistence to the host. Busy, error and cancelled states never rewrite the original.

The host supplies the selected passage, edit state and result. The toolbar anchors to that passage; actions and custom instructions only request work. Keep/Discard callbacks leave persistence to the host. Busy, error and cancelled states never rewrite the original.

Import

tsx1 line
import { SelectionActions } from "@yuhuanowo/yunui/ai";

Interactive example

The controls below explicitly simulate host responses; no request is sent. All labels and accessibility copy can be overridden. Missing callbacks disable the corresponding request controls.

SelectionActions

Integration note: Use the library controls directly rather than rebuilding each control.

The original passage remains until the host accepts a result.

Composition

tsx3 linesScroll horizontally
import { SelectionActions } from "@yuhuanowo/yunui/ai";

<SelectionActions selectedText="Use the public components." state="idle" />

Props

PropTypeDefaultDescription
actionsreadonly SelectionAction[][ { id: "Explain", action: "Explain", icon: <CircleHelp {...iconProps} /> }, { id: "Improve", action: "Improve", busyLabel: "Improving", icon: <Sparkles {...iconProps} /> }, { id: "Shorten", action: "Shorten", busyLabel: "Shortening", icon: <Scissors {...iconProps} /> }, { id: "Tone", action: "Change tone", busyLabel: "Changing tone", icon: <ThumbsUp {...iconProps} /> }, { id: "Grammar", action: "Fix grammar", icon: <Type {...iconProps} /> }, ]Host-owned actions. Omitting this uses the general-purpose default action set.
busyLabelReactNode—Current host activity label; used only while `state="busy"`.
classNamestring—
disabledbooleanfalse
labelsSelectionActionsLabels—
leadReactNode—Optional prose immediately before the selected passage.
onAccept((result: string) => void)—
onAction((action: string, instruction?: string) => void)—
onDismiss(() => void)—
onRetry(() => void)—
resultTextstring—Host-provided rewrite. It is never generated by this component.
selectedText*string—
state"idle" | "busy" | "result" | "error" | "cancelled"idleHost owns all request state; no internal request timer or optimistic result.

On this page