Accordion
Lists questions that each open their answer below them, one at a time or several at once.
Configurations
Supported configurations for this component.
States
Interaction states covered by the API and the style contract.
Configurations
3 examples- About five minutes, with one photo ID.
- Yes, and you keep your wallet and its history.
- About five minutes, with one photo ID.
States
2 examplesAdd to your project
One command adds this component to your project.
Run the following command. New project? Run npx shadcn@latest init first to set up Tailwind and path aliases.
npx shadcn@latest add @aicanvas/••••••••••••Light and dark both come with the install and follow the dark class on <html>, the shadcn dark mode setup (next-themes with attribute="class").
Props
Every prop this component accepts. Any other prop is forwarded to the underlying element.
Accordion
| Prop | Type | Default | Description |
|---|---|---|---|
| type | 'single'|'multiple' | 'single' | Single keeps one item open at a time; multiple opens items independently. |
| collapsible | boolean | true | Single only: the open item closes when its trigger is pressed again, leaving none open. False keeps one open at all times. |
| value | string|string[] | - | Controlled open value: a string for single ('' for none), an array for multiple. Pair with onValueChange. |
| defaultValue | string|string[] | - | Initial open value when uncontrolled, same shape as value. |
| onValueChange | (value: string | string[]) => void | - | Called with the next open value: a string for single, an array for multiple. |
| as | 'div'|'ol'|'ul' | 'div' | The list element. With 'ol' or 'ul' each item renders as an li, so a numbered list keeps its list semantics. |
| children | React.ReactNode | - | AccordionItems. |
| className | string | - | Additional CSS classes applied to the root element. |
| style | React.CSSProperties | - | Inline styles applied to the root element. |
AccordionItem
| Prop | Type | Default | Description |
|---|---|---|---|
| valuereq | string | - | Identifies the item in the group's open value. |
| disabled | boolean | false | The item cannot be toggled: Collapsible's disabled state (dimmed, not-allowed cursor). It keeps whatever open state the group gives it. |
| children | React.ReactNode | - | An AccordionTrigger followed by an AccordionContent. |
| className | string | - | Additional CSS classes applied to the root element. |
| style | React.CSSProperties | - | Inline styles applied to the root element. |
AccordionTrigger
| Prop | Type | Default | Description |
|---|---|---|---|
| childrenreq | React.ReactNode | - | The question, set at textLg in text.primary. |
| leading | React.ReactNode | - | A short index ("01") in the glyph slot before the question: label role, tabular, text.faint at rest, text.muted while open, hovered or focused. Without it the question starts at the row inset. |
| onClick | (event: React.MouseEvent<HTMLButtonElement>) => void | - | Runs before the toggle; call preventDefault to keep the item as it is. |
| className | string | - | Additional CSS classes applied to the root element. |
| style | React.CSSProperties | - | Inline styles applied to the root element. |
AccordionContent
| Prop | Type | Default | Description |
|---|---|---|---|
| children | React.ReactNode | - | The answer, set at textMd in text.secondary. Children stack in a column 12px apart. |
| className | string | - | Merged onto the answer's box. |
| style | React.CSSProperties | - | Merged onto the answer's box. |