# Regenerate stack

Answer versions as a deck: regenerate and the old answer slips back into a stack behind the new one, and stepping through brings each card forward.

Also called: regenerate animation, answer stack.

> 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: Versions in a deck. Regenerate and the old answer slips back into a stack behind the new one; step through versions and the deck reorders. Preview: https://chatcn.dev/preview/regenerate-stack-demo

Regenerate usually makes the answer you had disappear behind a 2 / 2 counter. Here it slips back and up into a deck behind the new one, its edge still showing, so you can see you kept it. Every version is a card in the same deck: stepping through brings that card forward while the others settle behind it in order of distance, and the count rolls with them. A version still being written shows the Thinking style label over skeleton lines.

## Installation

```bash
npx shadcn@latest add @chatcn-pro/regenerate-stack
```

## Usage

```tsx
import { RegenerateStack } from "@/components/ui/chatcn/pro/regenerate-stack"

<RegenerateStack
  versions={versions}
  index={index}
  onIndexChange={setIndex}
  onRegenerate={regenerate}
/>
```

## Props

| Prop | Type | Notes |
| --- | --- | --- |
| `versions` | `{ id, content: ReactNode | null }[]` | `null` content while that version is being written |
| `index` | `number` | The version in front |
| `onIndexChange` | `(index: number) => void` |  |
| `onRegenerate` | `() => void` | Shows the Regenerate button |
| `pendingLabel` | `string` | Default "Writing another version" |

## Accessibility

- Only the front card is in the accessibility tree; cards behind are `inert`.
- The count is announced politely as it changes.

## Motion

- Cards move on `translate`, `scale` and `opacity` only, 380 ms. Up to two edges peek, 8 px apart.
- The deck eases to the front card's height, measured live so a streaming version grows the deck with it.
- The regenerate icon makes one full turn per press. Reduced motion keeps the fades.

Source: https://chatcn.dev/docs/components/regenerate-stack