- 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/accordionThe CLI writes components/ui/accordion.tsx, installs Text,
Icon and Utils, and adds @rn-primitives/accordion, lucide-react-native,
react-native-reanimated and react-native-worklets. An Expo app built with babel-preset-expo compiles
Reanimated's worklets with no further setup.
Usage#
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@/components/ui/accordion';
import { Text } from '@/components/ui/text';<Accordion defaultValue={['item-1']}>
<AccordionItem value="item-1">
<AccordionTrigger>
<Text>Is it accessible?</Text>
</AccordionTrigger>
<AccordionContent>
<Text>Yes. Each trigger is announced as a button with its expanded state.</Text>
</AccordionContent>
</AccordionItem>
</Accordion>API reference#
Accordion#
Takes every prop of React Native's View, plus:
| Prop | Type | Default |
|---|---|---|
value | string[] | - |
defaultValue | string[] | [] |
onValueChange | (value: string[]) => void | - |
multiple | boolean | false |
disabled | boolean | false |
value lists the open items. Without it the Accordion holds its own, starting from defaultValue. One item
is open at a time: opening another closes it. With multiple, several can be open. Pressing an open item's
trigger closes it in both cases.
AccordionItem#
Takes every prop of React Native's View, plus a required value that names it and disabled. Every item
but the last draws a border under it. This holds for items placed directly inside the Accordion, including an
array from map; an item wrapped in a component of your own is not known to be the last.
AccordionTrigger#
Takes every prop of React Native's Pressable. It is announced as a button with its expanded and disabled
state. Its title goes in as a Text child, which wraps beside a chevron that points down while the item is
closed and up while it is open. A disabled trigger is dimmed and ignores presses.
AccordionContent#
Takes every prop of React Native's View. A closed item's content is not rendered. As the item opens, the
content grows from no height to its own over 200ms, and it shrinks back as the item closes. When the system
asks for reduced motion, it appears and goes at once. Its className goes on the padded box around the
children: space several Text children with a gap, such as gap-4.
Differences from upstream#
- Upstream's
renderprop becomesasChild, as on every native item. - The trigger takes its title as a Text child, not a string.
- Upstream spaces paragraphs in the content with a margin and underlines links in it through CSS selectors. React Native has no selectors, so space the children with a gap and style a link where you place it.
- Upstream's height animation runs whatever the system's motion setting. The native one is skipped when the system asks for reduced motion.
- No hover underline and no focus ring on the trigger; the native items draw no focus ring.
orientation,loopFocus,keepMountedandhiddenUntilFoundare left out: they serve arrow-key focus, a closed panel kept in the DOM, and the browser's find-in-page, none of which a device has.