- Label
- Icon label
- Field
- Form
- Frontmatter form
- Questionnaire
- Input
- Input group
- Input OTP
- Password input
- Password strength
- Code input
- Number field
- Tag input
- Textarea
- Checkbox
- Radio group
- Language toggle group
- Emoji appearance toggle group
- Emoji picker
- Avatar picker
- AI provider picker
- Select
- Native select
- Combobox
- Language combobox
- Slider
- Calendar
- Switch
- Alert
- Avatar
- Badge
- Card
- AI provider card
- Model info card
- Model list
- Empty
- Item
- Tree item
- File tree
- Icon media
- File type icon
- Font preview
- Image preview
- Kbd
- Table
- Data table
- Data table column header
- Chart
- Code Block
- Code card
- Markdown view
- Attachment
- Bubble
- Marker
- Message
- Chat message
- Chat suggestion item
- Message scroller
- Trace
- Progress
- Spinner
- Sonner
- Toast
- Unsaved changes toolbar
- Unsaved indicator
- Status indicator
- Permission card
- Separator
- Skeleton
- Animated grid pattern
- Meteors
Installation#
pnpm dlx shadcn@latest add @zui/collapsibleThe CLI writes components/ui/collapsible.tsx, installs Utils, and adds @rn-primitives/collapsible.
Usage#
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible';
import { Text } from '@/components/ui/text';<Collapsible>
<CollapsibleTrigger>
<Text>Can I use this in my project?</Text>
</CollapsibleTrigger>
<CollapsibleContent>
<Text>Yes. Free to use for personal and commercial projects.</Text>
</CollapsibleContent>
</Collapsible>To make a Button the trigger, pass asChild and name an icon-only
Button with aria-label:
<CollapsibleTrigger asChild>
<Button variant="ghost" size="icon" aria-label="Toggle">
<Icon as={ChevronsUpDown} />
</Button>
</CollapsibleTrigger>API reference#
Collapsible#
Takes every prop of React Native's View, plus:
| Prop | Type | Default |
|---|---|---|
open | boolean | - |
defaultOpen | boolean | false |
onOpenChange | (open: boolean) => void | - |
disabled | boolean | false |
Without open it holds its own state, starting from defaultOpen. With open it follows it, and a press
calls onOpenChange with the new value. It draws nothing of its own.
CollapsibleTrigger#
Takes every prop of React Native's Pressable, plus asChild. It is announced as a button with its expanded
state, named by its Text children. A disabled Collapsible's trigger is announced disabled and ignores
presses.
CollapsibleContent#
Takes every prop of React Native's View, plus:
| Prop | Type | Default |
|---|---|---|
keepMounted | boolean | false |
A closed content is not rendered, so what it holds loses its state. With keepMounted it stays rendered
while closed, hidden and out of the screen reader's reach.
Differences from upstream#
- Upstream's
renderprop becomesasChild, as on every native item. - Upstream's
hiddenUntilFoundis left out: it lets the browser's find-in-page open the panel, and a device has no find-in-page.