Accordion
Collapsible sections.
Installation
npx axiom add accordionpnpm dlx axiom add accordionyarn dlx axiom add accordionbun x axiom add accordionInstalls: react-native-reanimated, react-native-worklets.
Requires the chevron-down icon in your icon registry. Open sections, measuring and the height animation live in use-accordion.ts, shared by every styling variant.
Usage
import { Accordion } from "@/components/ui/accordion";
<Accordion type="single" collapsible>
<Accordion.Item value="shipping">
<Accordion.Trigger>Shipping</Accordion.Trigger>
<Accordion.Content>Orders ship within 2 days.</Accordion.Content>
</Accordion.Item>
</Accordion>;Props
Accordion
| Prop | Type | Default | Description |
|---|---|---|---|
type | 'single' | 'multiple' | 'single' | single: opening a section closes the others. multiple: several sections can stay open. |
value | string | string[] | — | Open section(s): a string for single, an array for multiple. |
defaultValue | string | string[] | — | Initially open section(s) when the accordion manages its own state. |
onValueChange | (value) => void | — | Called when a section opens or closes. |
collapsible | boolean | true | With type="single", lets the user close the open section. false always keeps one open. |
disabled | boolean | false | Disables every section. |
divider | boolean | true | Hairline between sections. |
children | ReactNode | — | Accordion.Item elements. |
style | StyleProp<ViewStyle> | — | Extra styles. |
Accordion.Item
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | — | Required. Identifies the section. |
disabled | boolean | false | Keeps this section closed and dims its trigger. |
style | StyleProp<ViewStyle> | — | Extra styles. |
Accordion.Trigger
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | — | The section title. |
icon | ReactNode | null | chevron | Indicator on the right, rotated when open. null hides it. |
leading | ReactNode | — | Content before the title, such as an icon. |
style | StyleProp<ViewStyle> | — | Extra styles. |
The trigger sets accessibilityRole="button" and accessibilityState.expanded.
Accordion.Content
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | — | The section body. It is measured once, then its height animates on the UI thread. |
forceMount | boolean | false | Keeps the content mounted while closed, to preserve its state (a form, a video position). |
style | StyleProp<ViewStyle> | — | Extra styles. |
Use cases
FAQ
type="single" so the screen doesn’t turn into a wall of open answers.
<Accordion type="single" collapsible>
{faq.map((q) => (
<Accordion.Item key={q.id} value={q.id}>
<Accordion.Trigger>{q.question}</Accordion.Trigger>
<Accordion.Content>
<Text color="muted">{q.answer}</Text>
</Accordion.Content>
</Accordion.Item>
))}
</Accordion>Order details
type="multiple" for sections the user compares, with a summary in the trigger.
<Accordion type="multiple" defaultValue={["items"]}>
<Accordion.Item value="items">
<Accordion.Trigger leading={<Icon name="bag" />}>
3 items
</Accordion.Trigger>
<Accordion.Content>{/* lines */}</Accordion.Content>
</Accordion.Item>
<Accordion.Item value="delivery">…</Accordion.Item>
</Accordion>Advanced options in a form
Keep rare settings out of the way. forceMount keeps what the user typed if they close the section.
<Accordion type="single" collapsible>
<Accordion.Item value="advanced">
<Accordion.Trigger>Advanced</Accordion.Trigger>
<Accordion.Content forceMount>
<Switch … />
<Input label="Bundle identifier" … />
</Accordion.Content>
</Accordion.Item>
</Accordion>