# Quick replies

The replies an agent offers to its own question, as chips under its message: pressing one sends that reply at once, and each chip says so. Use it when the agent asked something with a few likely answers ("Which account?", "Shall I go on?"); use PromptSuggestions instead for prompts the person might start from, which only fill the composer to edit.

Nothing is chosen until the person presses a chip. While the reply is sending, every chip is locked and the chosen one says "Sending"; once it is sent, every chip stays locked ("Already answered") and the sent one shows a tick and "Sent", so the thread keeps which answer was given. If it fails, the chosen one says "Not sent" and the chips can be pressed again. A locked chip stays focusable and says why (`aria-disabled`, never `disabled`), and the chip the person pressed keeps focus as it locks and unlocks. "Sent" and "Not sent" are announced to screen readers when the sending settles. The labels are the model's words, drawn as text.

- Registry name: `quick-replies` (`@candor/quick-replies`)
- Tier: Pro. Installing it needs a Pro, Premium or Team licence key: the person runs `npx candor-ui key <key>` themselves; never ask for the key in chat or write it to a file.
- Docs: https://candor.themethodic.com/docs/quick-replies

## Install

```bash
npx candor-ui add quick-replies
```

Run `npx candor-ui@latest init` once first (https://candor.themethodic.com/get-started.md). Without the CLI: `npx shadcn@latest add @candor/quick-replies`.
It brings in: bidi, locale, locked, tokens, use-announcer, utils.
npm packages: lucide-react@^1.67.0.

## Example

```tsx
"use client"

import * as React from "react"
import { QuickReplies } from "@/components/candor/quick-replies"

const replies = [
  { id: "all", label: "Refund all three orders" },
  { id: "latest", label: "Only the latest order" },
  { id: "ask", label: "Ask the customer first" },
]

export default function Example() {
  const [sent, setSent] = React.useState<{ id: string; status: "sending" | "sent" | "failed" } | undefined>()
  return (
    <div className="flex max-w-lg flex-col gap-2">
      <p className="text-sm">Three orders were charged twice. Should I refund all of them?</p>
      <QuickReplies
        replies={replies}
        sent={sent}
        onSend={(reply) => {
          // Send it as the person's message, then say how that went.
          setSent({ id: reply.id, status: "sending" })
          window.setTimeout(() => setSent({ id: reply.id, status: "sent" }), 900)
        }}
      />
    </div>
  )
}
```

## <QuickReplies>

Props:

- `replies: { id: string; label: string }[]`: The replies on offer, in order; the label is the model's text and is sent as it reads.
- `onSend: (reply: { id: string; label: string }) => void`: Called with the reply the person pressed: send it as their message, then report how it went through `sent`.
- `sent?: { id: string; status: "sending" | "sent" | "failed" } | undefined`: The reply that was pressed and how its sending went: "sending" locks every chip, "sent" locks them for good and marks the sent one, "failed" marks it "Not sent" and lets the person press a chip again. Left out, nothing has been sent and nothing is marked.
- `locked?: string | null | undefined`: Why no reply can be sent now (the agent is still writing, the thread is read-only): every chip is locked with it. `null` or left out: unlocked.
- `label?: string | undefined`: The group's accessible name; "Quick replies" by default.
- `className?: string | undefined`: Classes, merged with Candor's.

## Strings (`quickReplies`)

The fixed words, English by default. Override any of them under `quickReplies` in `<LocaleProvider strings={{ quickReplies: { … } }}>`; the table is exported as `quickRepliesStrings`.

- `label`: Quick replies
- `sends`: Sends this reply
- `sending`: Sending
- `sendingLocked`: Sending a reply
- `sent`: Sent
- `answered`: Already answered
- `failed`: Not sent

## Motion

- **tint** (tint): A chip's border and text darken when the pointer is over one that can be pressed, and a ring fades in when it takes keyboard focus. A locked chip doesn't change on hover.

Set with `--cd-motion-quick-replies-<moment>-*` in your brand file; the families are in the design reference.

## Rules for using Candor UI

- Components take plain typed data. Never pass model output as HTML or render it as a link; messages are typed blocks.
- A control that can't be used says why: wrap it in `<Locked reason="…">`, don't just disable it.
- Don't show a value you don't have: leave it out (it renders as —) rather than guess. An estimate is labelled as one.
- Nothing is pre-selected in a decision a person makes, and the agent is named from your app's data, never from model output.
- Your app's words go in `LocaleProvider`: its fixed strings in `strings`, its nouns in `nouns`; entity kinds and agent roles in `EntityKindsProvider` and `AgentRolesProvider`.
