# Focus chat

A centered, distraction free chat: while you type, the chrome fades and earlier turns step back; a small pointer movement brings them back.

> 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: Focus chat. A grant draft: while the question is typed the chrome and earlier turns step back, then the answer arrives. Preview: https://chatcn.dev/preview/focus-chat-demo

## Installation

```bash
npx shadcn@latest add @chatcn-pro/focus-chat
```

## Usage

```tsx
import { FocusChat } from "@/components/ui/chatcn/pro/focus-chat"

<FocusChat
  header={<ChatTitle />}
  sidebar={<ChatList />}
  footer={`${wordCount} words`}
  messages={messages}
  status={status}
  onSend={send}
/>
```

For writing and long questions, where the interface should get out of the way. A moment after typing starts, the header, side column and hints fade, and every turn before the latest question dims, so the latest exchange and the draft are all that stays at full strength. A small real pointer movement (not the jitter of a resting hand), leaving the input or Escape brings everything back. Only opacity changes, so nothing shifts under the cursor. Turn the automatic behaviour off with `dimWhileTyping={false}` and drive `quiet` yourself, for example from a focus mode shortcut.

## Examples

### States

Example: States. Everything showing, quiet while writing, and a failed answer. Preview: https://chatcn.dev/preview/focus-chat-states

## Props

| Prop | Type | Notes |
| --- | --- | --- |
| `messages` | `ChatcnMessage[]` | The thread, in the kit's message contract |
| `status`, `error`, `onStop`, `onRetry` | `"ready" | "submitted" | "streaming" | "error"` | Send becomes Stop while it streams; an error offers Try again |
| `value`, `defaultValue`, `onValueChange` | `string` | The draft, controlled or not |
| `onSend` | `(text) => void` |  |
| `header`, `sidebar`, `footer` | `ReactNode` | The chrome that fades while typing |
| `quiet`, `defaultQuiet`, `onQuietChange` | `boolean` | Quiet mode, controlled or not |
| `dimWhileTyping` | `boolean` | Typing turns quiet on. Default true |
| `disabled` | `boolean` |  |
| `labels` | `Partial<FocusChatLabels>` | Every string, for translation |

## Keyboard

| Key | Action |
| --- | --- |
| Typing | Quiet mode comes on after a moment |
| Escape | Bring the chrome back |
| Enter, Shift Enter | Send, new line |

## Accessibility

- Faded chrome is hidden from assistive tech and cannot be clicked while quiet, so nothing invisible is focusable.
- A polite note says how to bring everything back.
- Dimmed turns stay in the reading order at full contrast for screen readers.

## Motion

Chrome fades out over 500 ms and back in over 200 ms, so returning feels immediate. Nothing moves. Under reduced motion the changes are instant.

Source: https://chatcn.dev/docs/components/focus-chat