Collapsible
Free until 48 hours before arrival.
npx shadcn add @klarhimmel/collapsibleCopy for AIExamples
Basic
Controlled
Disabled
DetailsAbout, usage, props and more
One button that shows or hides extra content below it.
When to use
Use for
One optional region the person can open: a policy, advanced options.
Not for
A list of regions. Use Accordion.
Pairs with
Text, Field, Card.
Preview
Free until 48 hours before arrival. After that the first night is charged, and a no-show is charged in full.
Import
Import
- Files
- collapsible.tsx, in components/klarhimmel/ui/. With it: theme, utils. npm: lucide-react.
- Render in
- Render it inside <Theme>, once near the root of your app. Tokens and fonts are scoped to it, so outside it the component is unstyled.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
title | ReactNode | required | The always-visible line that opens and closes the rest. |
children | ReactNode | required | |
open | boolean | - | Controlled or uncontrolled state. |
defaultOpen | boolean | - | Controlled or uncontrolled state. |
onOpenChange | (open: boolean) => void | - | Controlled or uncontrolled state. |
disabled | boolean | - | The button does nothing. |
className | string | - | Extra classes, merged after the component's own. |
Accessibility
| Key | Does |
|---|---|
Enter / Space | Opens or closes the region |
Tab | Moves focus; the ring is always visible |