One section that opens and closes under its title.
$ pnpm dlx shadcn@latest add @dashral/collapsibleInstallation
$ pnpm dlx shadcn@latest add @dashral/collapsibleAdds the component, the components it builds on, its npm packages and the theme tokens it uses. Or by its full URL: https://dashral.com/r/collapsible.json
Usage
import { Input } from "@/components/dashral/input"
import { Collapsible } from "@/components/dashral/collapsible"
<Collapsible title="Advanced settings">
<Input label="Slug" defaultValue={project.slug} />
</Collapsible>Using the npm package? Import from @dashral/ui/components/collapsible instead, here and in the examples; the rest is the same.
Examples
API reference
Collapsible
Also takes every prop of Radix Collapsible(opens in a new tab).
| Prop | Type | Default |
|---|---|---|
title | ReactNodeMakes the trigger: a full-width button with a chevron. | — |
trigger | ReactElementYour own trigger in place of the title's, e.g. a Button. | — |
meta | ReactNodeWith title: at the end of its row, before the chevron, e.g. a count. | — |
children | ReactNodeWhat opens and closes. | — |
open / defaultOpen / onOpenChange | Control it yourself, or start it open. | — |
disabled | booleanIt can't be opened or closed. | false |
classNames | { trigger, content }Classes for each part. | — |
className | stringExtra classes, merged with cn() so yours win. | — |
Keyboard
| Keys | Action |
|---|---|
| EnterorSpace | Open or close |
Accessibility
- The trigger has aria-expanded and aria-controls pointing at the content.
Motion
- Opening, the height grows at a calm pace (--duration-considered) while the content fades in, dropping a little. Closing, the content fades out first while the height waits, then gathers speed (--ease-exit), so no line is cut through. The chevron turns on the spring.