- Accordion
- Action BarUpdated
- Alert Dialog
- Alert
- Announcement
- Aspect Ratio
- Autocomplete
- Avatar
- BadgeUpdated
- Bottom Navigation
- Breadcrumb
- Button Group
- Button
- CalendarUpdated
- CardUpdated
- Carousel
- Chart
- Checkbox
- Circular Progress
- Circular Slider
- Clipboard
- Collapsible
- Color Picker
- Combobox
- Command
- Context MenuUpdated
- Data List
- Date Picker
- DialogUpdated
- DrawerUpdated
- Editable
- FieldUpdated
- File Upload
- Float
- Floating Panel
- Frame
- Hint
- Hover Card
- Image Cropper
- Input Group
- Input OTP
- Input
- Item
- Kbd
- Link Overlay
- Listbox
- MarqueeUpdated
- Menu
- Native Select
- Number InputUpdated
- Pagination
- Popover
- Progress
- Prose
- QR Code
- Radio Group
- Rating
- Resizable
- Scroll Area
- Segment Group
- Select
- Separator
- Sheet
- Sidebar
- Signature Pad
- Skeleton
- Skip Nav
- Slider
- Spinner
- Status
- Steps
- Switch
- TableUpdated
- Tabs
- Textarea
- TimerUpdated
- ToastUpdated
- Toggle Group
- Toggle Tooltip
- Toggle
- Tooltip
- Tour
- Tree View
Installation#
pnpm dlx shadcn@latest add @shark/collapsible
Anatomy#
Collapsible ├── CollapsibleTrigger └── CollapsibleContent
Usage#
import { Collapsible, CollapsibleTrigger, CollapsibleContent } from "@/components/ui/collapsible";
<Collapsible> <CollapsibleTrigger>Can I use this in my project?</CollapsibleTrigger> <CollapsibleContent> Yes. Free to use for personal and commercial projects. No attribution required. </CollapsibleContent> </Collapsible>
Controlled#
Use the open and onOpenChange props to control the collapsible state programmatically.
❌
States#
Disabled#
Examples#
Nested#
Collapsibles can be nested to create hierarchical structures.
Partial Collapse#
Use the collapsedHeight prop to show a portion of the content when collapsed.
This is the first paragraph of content. When collapsed, only a portion of this content will be visible.
This is the second paragraph. It will be hidden when the collapsible is in its collapsed state.
This is the third paragraph. Expand the collapsible to see all the content.
This is the fourth paragraph. The collapsedHeight prop controls how much content is visible when collapsed.
Interactive elements (links, buttons, inputs) within the collapsed area automatically become inaccesible to prevent keyboard navigation to hidden content.
API Reference#
Collapsible#
Root component. Controls expand/collapse state and animation.
| Prop | Type | Default |
|---|---|---|
open | boolean | - |
defaultOpen | boolean | false |
onOpenChange | ({ open }: OpenChangeDetails) => void | - |
collapsedHeight | string | - |
className | string | - |
CollapsibleTrigger#
Toggles expand/collapse on click. Use asChild for custom trigger elements.
| Prop | Type | Default |
|---|---|---|
className | string | - |
asChild | boolean | false |
CollapsibleContent#
Holds the content that expands and collapses. Animated by default.
| Prop | Type | Default |
|---|---|---|
className | string | - |
asChild | boolean | false |
CollapsibleIndicator#
Chevron or icon that rotates to indicate open/closed state.
| Prop | Type | Default |
|---|---|---|
className | string | - |
asChild | boolean | false |
For a complete list of props, see the Ark UI documentation.