Components
Story
NativeSlides one after another with a bar of segments on top.
2026
Your year, in squares
Slide 1 of 4
Installation
npx nook-ui@latest add storyPrompt
Paste this into your AI coding assistant. It adds this exact component, the same way the CLI does, and tells the assistant how to use it.
Short. For assistants that can run commands in your project.
Add the Nook "Story" component to this project, exactly as Nook ships it.
Slides one after another with a bar of segments on top.
Steps
1. Check for `nook.json` in the project root. If it is missing, run `npx nook-ui@latest init` first (React or Next.js with Tailwind CSS v4). It adds the Nook tokens, the theme and `cn()`.
2. Run `npx nook-ui@latest add story`. It writes `components/ui/story.tsx` together with everything the component needs. Do not write the component from memory.
3. If you cannot run commands, fetch http://localhost:3000/r/story.json, write every entry of `files` to the path it names, install the packages in `dependencies`, and repeat for each name in `registryDependencies`.
4. Use it where I ask. Start from this example:
```tsx
import { Story } from "@/components/ui/story";
export default function StoryDefault() {
return (
<Story aria-label="Your year in review" duration={4} slides={[
<div key="1" className="grid gap-2"><p className="text-sm text-muted-foreground">2026</p><p className="text-4xl font-semibold tracking-tight">Your year, in squares</p></div>,
<div key="2" className="grid gap-2"><p className="text-6xl font-semibold tabular-nums">1,240</p><p className="text-muted-foreground">tasks finished</p></div>,
<div key="3" className="grid gap-2"><p className="text-6xl font-semibold tabular-nums">86</p><p className="text-muted-foreground">days in a row, your best streak</p></div>,
<div key="4" className="grid gap-2"><p className="text-3xl font-semibold tracking-tight">Thank you for planning with us.</p></div>,
]} />
);
}
```
API
- `Story`: The viewer.
- `slides` (`ReactNode[]`): One node per slide.
- `duration` (`number`): Seconds per slide. Default 5.
- `autoPlay` (`boolean`): Advance by itself. Default true.
- `aria-label` (`string`): Names the story.
Rules
- Colors, radii, shadows and motion come from Nook tokens and classes such as `bg-primary`, `text-muted-foreground`, `border-border`, `rounded-lg` and `h-control`. Never hard-code them.
- Do not restyle or simplify the file. Change how it looks through `className`, its props and the theme.
- It must keep working with the keyboard, in light and dark mode, and in the sharp, soft and bold styles.
- Accessibility: Press the right or left side, use the buttons or the arrow keys. It never plays by itself for people who prefer reduced motion, and holding pauses it. The slide number is announced.
Done when the component renders like the example in light and dark mode and the project type-checks.Usage
import { Story } from "@/components/ui/story";
export default function StoryDefault() {
return (
<Story aria-label="Your year in review" duration={4} slides={[
<div key="1" className="grid gap-2"><p className="text-sm text-muted-foreground">2026</p><p className="text-4xl font-semibold tracking-tight">Your year, in squares</p></div>,
<div key="2" className="grid gap-2"><p className="text-6xl font-semibold tabular-nums">1,240</p><p className="text-muted-foreground">tasks finished</p></div>,
<div key="3" className="grid gap-2"><p className="text-6xl font-semibold tabular-nums">86</p><p className="text-muted-foreground">days in a row, your best streak</p></div>,
<div key="4" className="grid gap-2"><p className="text-3xl font-semibold tracking-tight">Thank you for planning with us.</p></div>,
]} />
);
}Props
Story
The viewer.
| Prop | Type | Default | Description |
|---|---|---|---|
| slides | ReactNode[] | – | One node per slide. |
| duration | number | – | Seconds per slide. Default 5. |
| autoPlay | boolean | – | Advance by itself. Default true. |
| aria-label | string | – | Names the story. |
Accessibility
Press the right or left side, use the buttons or the arrow keys. It never plays by itself for people who prefer reduced motion, and holding pauses it. The slide number is announced.
Checked against WCAG 2.1 AA with automated axe tests and keyboard tests on every release.