# Persona onboarding

Role and goal questions that tailor the first chat, with that chat drawn beside them and redrawn on every answer.

> 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: Persona onboarding. Three questions about role, goals and answer style, with the first chat redrawn beside them on every answer. Preview: https://chatcn.dev/preview/persona-onboarding-demo

## Installation

```bash
npx shadcn@latest add @chatcn-pro/persona-onboarding
```

## Usage

```tsx
import { PersonaOnboarding } from "@/components/ui/chatcn/pro/persona-onboarding"

<PersonaOnboarding
  questions={[
    { id: "role", title: "What do you do?", options: [{ value: "design", label: "Design" }, …] },
    { id: "goals", title: "What will you use it for first?", multiple: true, options: […] },
  ]}
  tailor={(answers) => ({
    greeting: "Hi. Here is where designers usually start.",
    starters: [{ title: "Critique this flow", reason: "For designers", from: "role" }],
    defaults: [{ label: "Model", value: "Claude Sonnet 5.5", from: "goals" }],
  })}
  onDone={(answers, preview) => saveWorkspace(answers, preview)}
  onSkip={useDefaults}
/>
```

One question at a time, single or pick any, and every one can be skipped: Next reads Skip question until something is picked. `tailor` turns the answers into the first chat (a greeting, starters and defaults such as the model or answer style) and runs on every change, so the preview beside the question is always the real result. Only what an answer changed moves: starters that stay keep their place and new ones rise in. Tag a starter or default with `from`, the question that shaped it, and it is outlined while that question is on screen, so the reader sees what each answer is for before giving it. Wide frames put the preview beside the questions; narrow ones put it underneath.

## Examples

### States

Example: States. Nothing answered yet, the goals question with what it shapes lit, and a narrow frame where the preview stacks. Preview: https://chatcn.dev/preview/persona-onboarding-states

## Props

| Prop | Type | Notes |
| --- | --- | --- |
| `questions` | `PersonaQuestion[]` | `{ id, title, hint?, options, multiple? }` |
| `tailor` | `(answers) => PersonaPreview` | `{ greeting, starters, defaults? }`; keep it pure |
| `value`, `defaultValue`, `onValueChange` | `Record<string, string[]>` | The answers |
| `step`, `defaultStep`, `onStepChange` | `number` | The question on screen |
| `onDone` | `(answers, preview) => void` | Start chatting, on the last question |
| `onSkip` | `() => void` | Shows Skip setup |
| `labels` | `Partial<PersonaOnboardingLabels>` | Every string, for translation |

## Keyboard

| Key | Action |
| --- | --- |
| Tab | Moves between the choices and the buttons |
| Arrow keys | Move between choices |
| Enter, Space | Pick a choice |

## Accessibility

- Choices are toggle buttons in a group named by the question, and report whether they are pressed.
- Stepping moves focus to the new question's heading.
- The preview is a labelled region and its greeting is announced politely when it changes.

## Motion

A new question slides in 12 px from the side it came from over 220 ms. New starters and defaults rise 4 px over 240 ms; unchanged ones stay still. Nothing moves on first paint or under reduced motion.

Source: https://chatcn.dev/docs/components/persona-onboarding