Data display
Accordion
A single expandable section: an Accordion.Summary row that toggles an animated Accordion.Content body.
import { Accordion, AccordionSummary, AccordionContent, AccordionIcon } from "datui";Examples
Basic
Unlimited projects, 100 GB of storage and priority support.
Yes, from the billing page.
Controlled, one at a time
Use open/onOpenChange to keep only one section open. unmountOnCollapse drops closed content.
Name, email and password.
Accessibility
- The summary is a
<button>witharia-expandedandaria-controls; Enter and Space toggle it. - The content is a
role="region"labelled by the summary. - Collapsed content is
inertandvisibility: hidden(or unmounted withunmountOnCollapse), so it is out of the tab order and hidden from assistive tech. - The height animation uses motion tokens and is instant under
prefers-reduced-motion. disableddisables the summary button.
API
Accordion
Single expandable section: `Accordion.Summary` row plus `Accordion.Content` body.
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | — | |
| defaultOpen | boolean | false | |
| disabled | boolean | — | |
| onOpenChange | ((open: boolean) => void) | — | |
| open | boolean | — | |
| unmountOnCollapse | boolean | false | Remove the content from the DOM when collapsed (after the closing animation). |
AccordionSummary
Header row that toggles the Accordion. A `button` with `aria-expanded` and `aria-controls`.
| Prop | Type | Default | Description |
|---|---|---|---|
| activated | boolean | — | Keep the pressed look, e.g. for the active item of a list. |
| after | ReactNode | — | Trailing content, e.g. a switch, counter or button-free text. |
| as | ElementType<any, keyof IntrinsicElements> | — | Element to render. Defaults to `a` with `href`, `button` with `onClick`, otherwise `div`. |
| badgeAfterSubtitle | ReactNode | — | |
| badgeAfterTitle | ReactNode | — | |
| badgeBeforeSubtitle | ReactNode | — | |
| badgeBeforeTitle | ReactNode | — | |
| before | ReactNode | — | Leading content, e.g. an icon or avatar. |
| className | string | — | |
| collapseIcon | ElementType<any, keyof IntrinsicElements> | animated chevron up | |
| disabled | boolean | — | |
| expandIcon | ElementType<any, keyof IntrinsicElements> | animated chevron down | |
| extraSubtitle | ReactNode | — | |
| hasActive | boolean | true | Background tint while pressed. |
| hasHover | boolean | true | Background tint on hover. |
| href | string | — | |
| iconPosition | "none" | "before" | "after" | after | Where the expand icon sits; `none` hides it. |
| indicator | ReactNode | — | Secondary value shown before `after`, e.g. the current setting. |
| multiline | boolean | false | Wrap long text instead of truncating it. |
| overTitle | ReactNode | — | Small text above the title. |
| rel | string | — | |
| subtitle | ReactNode | — | |
| target | string | — | |
| type | "button" | "submit" | "reset" | — |
AccordionContent
Collapsible body. A `region` labelled by the summary, hidden from assistive tech while collapsed.
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | — |
AccordionIcon
Expand/collapse icon bound to the surrounding Accordion's state, for custom summaries.
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | — | |
| collapseIcon | ElementType<any, keyof IntrinsicElements> | animatedIcon("chevron-up", (c) => ( <motion.path animate={c} variants={nudge("y", -2)} d="m18 15-6-6-6 6" /> )) | Icon shown while expanded. |
| expandIcon | ElementType<any, keyof IntrinsicElements> | animatedIcon("chevron-down", (c) => ( <motion.path animate={c} variants={nudge("y", 2)} d="m6 9 6 6 6-6" /> )) | Icon shown while collapsed. |