Accordion
Folds sections of content under their titles, one or many open at a time.
Installation
npm i @uisatin/uiimport { Accordion, AccordionItem } from '@uisatin/ui/accordion'About 19.2 kB of JavaScript, minified and gzipped, with what it imports (React aside). The stylesheet is one file for every component.
npx shadcn@latest add https://uisatin.dev/r/accordion.jsonAdds accordion.tsx to components/ui and installs radix-ui.
First time with Satin? Set it up once, styles and fonts included, with the installation guide.
API Reference
The Accordion component wraps the Radix accordion in a div that holds AccordionItems; each item renders a button header with aria-expanded and its content under it. The item.* props belong to AccordionItem.
| Prop | Type | Default |
|---|---|---|
type | "single""multiple" | — |
collapsible | boolean | false |
defaultValue | stringstring[] | — |
item.value | string | — |
item.title | ReactNode | — |
item.icon | ReactNode | — |
item.children | ReactNode | — |
className | string | — |
ref | Ref<HTMLElement> | — |
...props | ComponentProps<typeof Accordion.Root>Other attributes go to the Radix Accordion.Root part | — |
Accessibility
Each header is a button inside a heading, with aria-expanded and aria-controls pointing at its section, which is a region labelled by the header. A closed section leaves the accessibility tree. The chevron and the icon are hidden from screen readers.
| Key | Action |
|---|---|
| EnterorSpace | Opens or closes the focused section. With type="single", the open one closes only when collapsible. |
| ↓ | Moves focus to the next header, wrapping to the first. |
| ↑ | Moves focus to the previous header, wrapping to the last. |
| Home | Moves focus to the first header. |
| End | Moves focus to the last header. |
Something wrong or missing on this page?
Report a problemSuggest an improvement