# Focus reader

A long answer that reads with you, sentence by sentence.

Also called: reading mode.

> 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: An answer that reads with you. The sentence you are on stays in full ink while the rest settle back, a guide glides to it in the margin, and with read aloud a highlighter sweeps it in time with the voice. Preview: https://chatcn.dev/preview/focus-reader-demo

The sentence you are on stays in full ink while the ones behind settle back and the ones ahead wait faint, and a guide in the margin glides to each new sentence on a spring. With read aloud, a highlighter sweeps through the sentence in time with the voice, across line breaks, the way a finger follows a line.

## Installation

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

## Usage

```tsx
import { FocusReader } from "@/components/ui/chatcn/pro/focus-reader"

<FocusReader text={answer} index={sentence} onIndexChange={seek} sentenceMs={durations[sentence]} />
```

## Props

| Prop | Type | Notes |
| --- | --- | --- |
| `text` | `string` | Split into sentences inside |
| `index` / `onIndexChange` | `number` | Optional control |
| `sentenceMs` | `number` | With read aloud: sweeps the highlighter in time |

## Keyboard

| Key | Action |
| --- | --- |
| `Arrow keys` / `J` / `K` | Next or previous sentence |

## Accessibility

- The current sentence carries `aria-current`.

## Motion

- Colours fade 300 ms; the guide rides a critically damped spring; the sweep is linear. Reduced motion: no sweep.

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