Components
Accordion
Built on Base UIStacked sections that open and close, one at a time or several.
Yes. You have 14 days to settle a request before we send a reminder to you and the person who paid.
Installation
npx nook-ui@latest add accordionPrompt
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 "Accordion" component to this project, exactly as Nook ships it.
Stacked sections that open and close, one at a time or several.
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 accordion`. It writes `components/ui/accordion.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/accordion.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 { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "@/components/ui/accordion";
export default function AccordionDefault() {
return (
<Accordion defaultValue={["later"]} className="max-w-lg">
<AccordionItem value="later">
<AccordionTrigger>Can I pay later?</AccordionTrigger>
<AccordionContent>Yes. You have 14 days to settle a request before we send a reminder to you and the person who paid.</AccordionContent>
</AccordionItem>
<AccordionItem value="reminders">
<AccordionTrigger>How do reminders work?</AccordionTrigger>
<AccordionContent>We send one message after 3 days and one after 10. You can turn them off for any bill.</AccordionContent>
</AccordionItem>
<AccordionItem value="fees">
<AccordionTrigger>Are there fees?</AccordionTrigger>
<AccordionContent>Splitting is free. Card payments cost 1.5%, bank transfers cost nothing.</AccordionContent>
</AccordionItem>
</Accordion>
);
}
```
API
- `Accordion`: The group.
- `defaultValue` (`unknown[]`): Values of the sections open at first.
- `multiple` (`boolean`, default false): Allow several open sections.
- `AccordionItem`: One section.
- `value` (`unknown`): Identifies the section.
- `AccordionTrigger`: The heading and its button.
- `AccordionContent`: The collapsible content.
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: Each trigger is a button inside a heading with `aria-expanded`. Enter and Space toggle; arrow keys move between triggers.
Done when the component renders like the example in light and dark mode and the project type-checks.Usage
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "@/components/ui/accordion";
export default function AccordionDefault() {
return (
<Accordion defaultValue={["later"]} className="max-w-lg">
<AccordionItem value="later">
<AccordionTrigger>Can I pay later?</AccordionTrigger>
<AccordionContent>Yes. You have 14 days to settle a request before we send a reminder to you and the person who paid.</AccordionContent>
</AccordionItem>
<AccordionItem value="reminders">
<AccordionTrigger>How do reminders work?</AccordionTrigger>
<AccordionContent>We send one message after 3 days and one after 10. You can turn them off for any bill.</AccordionContent>
</AccordionItem>
<AccordionItem value="fees">
<AccordionTrigger>Are there fees?</AccordionTrigger>
<AccordionContent>Splitting is free. Card payments cost 1.5%, bank transfers cost nothing.</AccordionContent>
</AccordionItem>
</Accordion>
);
}Examples
Several open
Three projects, 1 GB of storage and community support.
Yes, up to 5 people. Each extra seat is $8 per month.
Disabled item
Rich content
We prepare a ZIP with your projects, comments and files. It usually takes a few minutes.
- Projects as JSON
- Comments as CSV
Inside a card
Returns
Props
Accordion
The group.
| Prop | Type | Default | Description |
|---|---|---|---|
| defaultValue | unknown[] | – | Values of the sections open at first. |
| multiple | boolean | false | Allow several open sections. |
AccordionItem
One section.
| Prop | Type | Default | Description |
|---|---|---|---|
| value | unknown | – | Identifies the section. |
AccordionTrigger
The heading and its button.
AccordionContent
The collapsible content.
Accessibility
Each trigger is a button inside a heading with `aria-expanded`. Enter and Space toggle; arrow keys move between triggers.
Checked against WCAG 2.1 AA with automated axe tests and keyboard tests on every release.