nook
Browse the docs

Components

Slides

Native

A responsive 16:9 presentation viewer with navigation, thumbnails, speaker notes and print pages.

See the prompt

1 / 4 slides

Installation

npx nook-ui@latest add slides

Prompt

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.

Plain text
Add the Nook "Slides" component to this project, exactly as Nook ships it.

A responsive 16:9 presentation viewer with navigation, thumbnails, speaker notes and print pages.

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 slides`. It writes `components/ui/slides.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/slides.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 { Slides } from "@/components/ui/slides";
import { BarChart } from "@/components/ui/bar-chart";

const deck = [
  <div key="cover" className="flex h-full flex-col justify-between bg-brand p-16 text-brand-foreground"><p className="text-2xl">Fieldwork / Quarterly update</p><h3 className="text-8xl leading-none font-semibold tracking-tight">Good work.<br />More of it.</h3><p className="text-xl">Q3 2026 · Illustrative team report</p></div>,
  <div key="story" className="flex h-full flex-col justify-center gap-10 bg-card p-16 text-card-foreground"><h3 className="text-6xl font-semibold tracking-tight">Small teams.<br />Steady progress.</h3><div className="grid grid-cols-3 gap-10 border-t border-border pt-8">{[["12", "projects shipped"], ["94%", "on-time delivery"], ["4.8 / 5", "client feedback"]].map(([metric, title]) => <div key={title}><p className="text-4xl font-medium tabular-nums">{metric}</p><p className="mt-3 text-xl text-muted-foreground">{title}</p></div>)}</div></div>,
  <div key="chart" className="grid h-full content-center gap-8 bg-card p-12 text-card-foreground"><h3 className="text-4xl font-semibold tracking-tight">Making space for deeper work.</h3><BarChart title="Illustrative focus hours per month" categoryKey="month" data={[{ month: "July", hours: 120 }, { month: "August", hours: 156 }, { month: "September", hours: 192 }]} series={[{ key: "hours", label: "Focus hours" }]} variant="dots" /><p className="text-lg text-muted-foreground">Protected focus hours, July–September 2026.</p></div>,
  <div key="close" className="flex h-full flex-col justify-between bg-foreground p-16 text-background"><span className="size-10 bg-brand" /><h3 className="text-7xl leading-tight font-semibold tracking-tight">Keep the focus.<br />Share the credit.</h3><p className="text-2xl">Next: make the October plan together.</p></div>,
];
export default function SlidesDefault() {
  return <Slides label="Fieldwork quarterly update" slides={deck} thumbnails notes={["Welcome the team. This report uses illustrative numbers.", "Thank everyone who helped keep projects moving.", "Describe how protected mornings helped the team find uninterrupted time.", "Leave ten minutes for questions and the next quarter's priorities."]} />;
}
```

API
- `Slides`: A fixed design stage scaled to its container. Shortcuts are scoped to the focused viewer and ignore editable fields.
  - `slides` (`readonly ReactNode[]`): The slide contents. Empty decks show a clear empty state.
  - `label` (`string`, default Presentation): Names the viewer region.
  - `value / defaultValue` (`number`, default 0): Controlled or initial zero-based slide index.
  - `onValueChange` (`(index: number) => void`): Receives navigation changes.
  - `thumbnails` (`boolean`, default false): Show a scrollable strip of slide previews.
  - `notes` (`readonly ReactNode[]`): Optional speaker notes for each slide.
  - `stageWidth` (`number`, default 960): Design width in pixels, scaled to the container at a 16:9 ratio.
  - `...props` (`React.HTMLAttributes<HTMLDivElement>`): Everything the native element accepts, such as `id`, `aria-*` and event handlers.

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: Arrows and PageUp/PageDown navigate; Home/End jump. F toggles browser full screen, Escape exits and closes notes. Native controls retain their keyboard activation. The counter announces changes politely. Thumbnails are decorative previews with labelled buttons. Print displays every slide on a separate page.

Done when the component renders like the example in light and dark mode and the project type-checks.

Usage

import { Slides } from "@/components/ui/slides";
import { BarChart } from "@/components/ui/bar-chart";

const deck = [
  <div key="cover" className="flex h-full flex-col justify-between bg-brand p-16 text-brand-foreground"><p className="text-2xl">Fieldwork / Quarterly update</p><h3 className="text-8xl leading-none font-semibold tracking-tight">Good work.<br />More of it.</h3><p className="text-xl">Q3 2026 · Illustrative team report</p></div>,
  <div key="story" className="flex h-full flex-col justify-center gap-10 bg-card p-16 text-card-foreground"><h3 className="text-6xl font-semibold tracking-tight">Small teams.<br />Steady progress.</h3><div className="grid grid-cols-3 gap-10 border-t border-border pt-8">{[["12", "projects shipped"], ["94%", "on-time delivery"], ["4.8 / 5", "client feedback"]].map(([metric, title]) => <div key={title}><p className="text-4xl font-medium tabular-nums">{metric}</p><p className="mt-3 text-xl text-muted-foreground">{title}</p></div>)}</div></div>,
  <div key="chart" className="grid h-full content-center gap-8 bg-card p-12 text-card-foreground"><h3 className="text-4xl font-semibold tracking-tight">Making space for deeper work.</h3><BarChart title="Illustrative focus hours per month" categoryKey="month" data={[{ month: "July", hours: 120 }, { month: "August", hours: 156 }, { month: "September", hours: 192 }]} series={[{ key: "hours", label: "Focus hours" }]} variant="dots" /><p className="text-lg text-muted-foreground">Protected focus hours, July–September 2026.</p></div>,
  <div key="close" className="flex h-full flex-col justify-between bg-foreground p-16 text-background"><span className="size-10 bg-brand" /><h3 className="text-7xl leading-tight font-semibold tracking-tight">Keep the focus.<br />Share the credit.</h3><p className="text-2xl">Next: make the October plan together.</p></div>,
];
export default function SlidesDefault() {
  return <Slides label="Fieldwork quarterly update" slides={deck} thumbnails notes={["Welcome the team. This report uses illustrative numbers.", "Thank everyone who helped keep projects moving.", "Describe how protected mornings helped the team find uninterrupted time.", "Leave ten minutes for questions and the next quarter's priorities."]} />;
}

Props

Slides

A fixed design stage scaled to its container. Shortcuts are scoped to the focused viewer and ignore editable fields.

PropTypeDefaultDescription
slidesreadonly ReactNode[]–The slide contents. Empty decks show a clear empty state.
labelstringPresentationNames the viewer region.
value / defaultValuenumber0Controlled or initial zero-based slide index.
onValueChange(index: number) => void–Receives navigation changes.
thumbnailsbooleanfalseShow a scrollable strip of slide previews.
notesreadonly ReactNode[]–Optional speaker notes for each slide.
stageWidthnumber960Design width in pixels, scaled to the container at a 16:9 ratio.
...propsReact.HTMLAttributes<HTMLDivElement>–Everything the native element accepts, such as `id`, `aria-*` and event handlers.

Accessibility

Arrows and PageUp/PageDown navigate; Home/End jump. F toggles browser full screen, Escape exits and closes notes. Native controls retain their keyboard activation. The counter announces changes politely. Thumbnails are decorative previews with labelled buttons. Print displays every slide on a separate page.

Checked against WCAG 2.1 AA with automated axe tests and keyboard tests on every release.