# Feedback switch

A shadcn/ui thumbs up / down rating for AI answers and help articles: the pressed thumb stretches into a thank-you with Undo, plus confetti.

> For the complete documentation index, see [llms.txt](/llms.txt). Markdown variants are available for the docs, pricing and about pages: append `.md` to the URL or send an `Accept: text/markdown` header (the home page answers the header too). An agent skill is available at [/.well-known/agent-skills/site-skill.md](/.well-known/agent-skills/site-skill.md).

## At a glance

- **Good for:** Rating AI chat and assistant answers; Was this helpful? prompts on docs pages; Help center and support article feedback; Rating search results and recommendations
- **Category:** Click & press, Loading & state · **Type:** Buttons · **Style:** Motion, Minimal, Dark mode
- **See it:** [Live preview](https://www.craftui.space/docs/interactions/feedback-switch)

## Install

```bash
pnpm dlx shadcn@latest add https://www.craftui.space/r/feedback-switch.json
```

Free to install.

## Usage

```tsx
import FeedbackSwitch from "@/components/interactions/feedback-switch/feedback-switch";

export default function Page() {
  return <FeedbackSwitch />;
}
```

With no props it renders with demo content; pass your own through the props below.

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `onChange` | `(vote: FeedbackVote \| null) => void` | — | Called with the vote when someone picks a thumb, and with `null` when they undo it. Not called by `demo`. |
| `labels` | `Partial<FeedbackSwitchLabels>` | — | Replaces any of the default words (English). |
| `demo` | `boolean` | `false` | Plays the vote and the undo on a loop while in view and untouched, with no Tab stops. For previews and gallery cards. |
| `className` | `string` | — | Classes for the row. Every size is in em of its font size, so a text size class (`text-lg`, `text-[26px]`) scales the whole switch. |

### `FeedbackSwitchLabels`

| Field | Type | Description |
| --- | --- | --- |
| `up` (required) | `string` | Accessible name of the thumbs-up pill. |
| `down` (required) | `string` | Accessible name of the thumbs-down pill. |
| `received` (required) | `string` | The sentence the chosen pill grows to show. |
| `undo` (required) | `string` | The text of the button that takes the vote back. |

## Files

The install adds:

- `components/interactions/feedback-switch/feedback-switch.tsx`
- `components/interactions/feedback-switch/DESIGN.md`

npm dependencies (installed for you): `motion`.