# TriageDeck

Decisions at the speed of a gesture: fling the top card toward a decision, or use arrows and buttons — with tallies and an undo that flies the card back.

- Family: Signature, imported from `mizu-ui` or `mizu-ui/signature`
- Docs: https://mizu.user64bit.world/components/triage-deck
- Source: https://github.com/0xuser64bit/mizu/blob/main/packages/mizu/src/signature/TriageDeck.tsx

## Usage

```tsx
"use client";

import { TriageDeck } from "mizu-ui";

export function Example() {
  return (
    <TriageDeck
      label="Inbox"
      items={[
        { id: "a", title: "Invoice from Northworks" },
        { id: "b", title: "Team offsite dates" },
      ]}
      itemLabel={(m) => m.title}
      decisions={[
        { id: "archive", label: "Archive", direction: "left" },
        { id: "keep", label: "Keep", direction: "right", tone: "success" },
      ]}
      renderItem={(m) => <h3 style={{ margin: 0, fontSize: 24 }}>{m.title}</h3>}
    />
  );
}
```

## Copy it with the shadcn CLI

```sh
npx shadcn@latest init 0xuser64bit/mizu/preset # once, where there is no components.json
npx shadcn@latest add 0xuser64bit/mizu/triage-deck
```

## Props

- `label / items / renderItem`: `string / T[] / (item) => ReactNode`. Region name, the queue (each with an id) and a card body.
- `itemLabel`: `(item) => string`. A short name used in announcements and the deck's label.
- `decisions`: `TriageDecision[]`. id, label, direction (left, right or up — one each) and tone.
- `onDecide / onUndo`: `(item, decision) => void`. Record or reverse a decision.
- `empty`: `ReactNode`. Shown when every item has been decided.

## Keyboard

- ← →: Decide left or right
- ↑: Decide up, when offered
- Backspace Z: Undo the last decision

## Accessibility

The deck is a focusable group named after the current item and its position. Arrow keys make the decisions a fling would; every decision also has a labelled button with its key, and Backspace undoes. Each decision announces what happened and what comes next. Tallies are a labelled list.

## Motion

The top card follows your hand and tilts with it; decision stamps fade in as you cross a threshold, and release velocity carries it off. The next card steps forward in depth, and an undone card flies back from the side it left by. Reduced motion decides without flight or tilt.
