Selection Actions

Highlight a passage and hand it to the agent to rewrite.

Installation

pnpm dlx shadcn@latest add @ward/selection-actions

Add the Ward registry to components.json once:

"registries": {
  "@ward": "https://ward.so/r/{name}.json"
}

Or install from the URL with no configuration: npx shadcn@latest add https://ward.so/r/selection-actions.json

Usage

import SelectionActions from "@/components/ward/SelectionActions";
<SelectionActions
  text={{
    lead: "Pistachio holds the top slot all weekend. ",
    original: "Plan it first thing Saturday so the batch can firm up.",
    rewrite: "Plan pistachio first thing Saturday so the batch has time to firm up.",
  }}
  labels={{ keep: "Keep", discard: "Discard", placeholder: "Describe edits" }}
  onAction={(action) => console.log(action)}
/>

Props

PropTypeDefaultDescription
variantstring"Default"Accepted so the Ward preview can pass a variant; the bar has a single look and ignores it.
textPartial<SelectionText>-Lead-in text, the selected passage and the rewrite streamed in its place, merged over the sample passage.
actionsSelectionActionSetDEFAULT_ACTIONSActions shown in the bar, with primary ones always visible and the rest revealed by the expand button.
labelsPartial<SelectionActionsLabels>-Copy for the Keep and Discard buttons and the prompt placeholder, merged over the built-in strings.
onAction(action: string) => void-Called with the action name or typed instruction whenever an edit is run.

Ward · Version 1.1.0 · Registry manifest