# Checklist widget

Steps an assistant laid out, to tick off in the chat, with a progress bar of one segment per step and drag to reorder.

> chatcn Pro: needs a Pro license (https://chatcn.dev/pro). Install from the `@chatcn-pro` registry with your license token; setup at https://chatcn.dev/docs/chatcn-pro.

Example: Checklist widget. Steps for a trip. Tick them off, drag one by its handle, or add your own. Preview: https://chatcn.dev/preview/checklist-widget-demo

## Installation

```bash
npx shadcn@latest add @chatcn-pro/checklist-widget
```

## Usage

```tsx
import { ChecklistWidget } from "@/components/ui/chatcn/pro/checklist-widget"

<ChecklistWidget
  title="Before you fly"
  meta={["Tokyo", "Friday"]}
  defaultItems={[
    { id: "passport", label: "Check your passport", done: true },
    { id: "esim", label: "Buy an eSIM", detail: "Install it before you fly" },
  ]}
  onItemsChange={save}
  addable
/>
```

The bar under the title has a segment per step in step order, so progress reads as which steps, not only how many. Ticking a step draws its check left to right and fills its segment; when the last one is ticked the bar, the boxes and the count turn green. Drag a step by its handle, which shows on hover and always on touch, and the steps it passes slide aside; or focus the handle and use the arrow keys, or press Alt with the arrow keys on a step. Moves are announced. `reorderable={false}` keeps a fixed order for steps that must run in sequence. `addable` adds a field at the end.

## Examples

### States

Example: States. Everything done, and a fixed order with nothing ticked. Preview: https://chatcn.dev/preview/checklist-widget-states

## Props

| Prop | Type | Notes |
| --- | --- | --- |
| `items`, `defaultItems`, `onItemsChange` | `ChecklistItem[]` | `{ id, label, detail?, done? }` |
| `title`, `meta` |  | The header; the count sits beside it |
| `reorderable` | `boolean` | Default true |
| `addable` | `boolean` | A field to add steps |
| `labels` | `Partial<ChecklistWidgetLabels>` | Every string, for translation |

## Keyboard

| Key | Action |
| --- | --- |
| Space | Tick or untick a step |
| Arrow up, down on a handle | Move the step |
| Alt and arrow up, down on a step | Move the step |
| Enter in the field | Add the step |

## Accessibility

- Steps are real checkboxes inside labels.
- Handles are buttons named for their step; every move is announced in a polite live region.

## Motion

Checks draw in with clip-path over 300 ms and segments fill with scale. Passed steps slide with translate. Under reduced motion they change in place.

Source: https://chatcn.dev/docs/components/checklist-widget