Accordion
In-flow disclosure with explicit expanded state and no hidden focusable children.
npx @swipeui/cli add accordionVariant
Preset
Material
Scheme
Feel
When to use it
- FAQ and help screens where each question opens to show its answer.
- Settings or product details grouped into sections people open one at a time.
- Long pages where collapsing sections keeps everything scannable.
- Several sections that can be open together (multiple).
When not to use it
- A single card that expands. Use Expandable card.
- Truncated paragraphs. Use Expandable text.
- Navigation to other screens. Use List row with a chevron.
Installation
Run this from your app's root. If SwipeUI isn't set up yet, run npx @swipeui/cli init first; it sets up Uniwind, the theme tokens and the cn helper.
npx @swipeui/cli add accordion- Adds
components/swipeui/ui/use-accordion-disclosure.ts,components/swipeui/ui/accordion.tsxand 7 shared helpers. - Installs react-native-reanimated, react-native-worklets, uniwind, clsx, tailwind-merge, expo-haptics, class-variance-authority. In Expo apps it uses
npx expo installso versions match your SDK.
Usage
import { Accordion } from '@/components/swipeui/ui/accordion';
<Accordion
items={[
{ id: 'delivery', title: 'Delivery', content: <Text>Arrives in three days.</Text> },
{ id: 'returns', title: 'Returns', content: <Text>Contact support to return it.</Text> },
]}
/>;API reference
| Prop | Type | Default | Description |
|---|---|---|---|
surface? | | | Group treatment. |
indicator? | | | Drawn disclosure indicator. |
animateContent? | | | Animate disclosure size changes. |
animateIndicator? | | | Animate the disclosure indicator. |
items | | — | Sections in reading order. |
value? | | — | Controlled expanded identifiers. |
defaultValue? | | | Initial expanded identifiers. |
onValueChange? | | — | Reports disclosure intent. |
multiple? | | | Allow more than one expanded section. |
disabled? | | — | Prevent all changes. |
haptics? | | | Press feedback. |
motion? | | — | Shared press/layout character. |
className? | | — | Root classes. |
style? | | — | Root layout escape hatch. |
testID? | | — | Root identifier. |
Composition and behavior
- items each have an id, title, content and optional disabled.
- multiple allows several open sections.
- Control with value and onValueChange, or defaultValue.
Behavior and gestures
- Tap a section header to open it; the content slides in and the page re-flows smoothly.
- By default opening one section closes the others; with multiple, they stay open.
- Tap an open header to close it.
- Disabled sections, or a disabled accordion, can't be toggled.
Accessibility
- Each header is a button named by its title that reports expanded or collapsed.
- Collapsed content is removed, so screen readers and keyboards never land on hidden controls.
- The chevron is decorative.
- Headers are at least 44 points tall.
Motion
- Uses the
layout,pressandselectmotion roles, so it follows your app's feel. Passmotionto tune this one instance. - Opening and closing use the layout spring.
- Reduce Motion makes it instant.
Performance
- Open sections and closing transitions render their contents; settled collapsed sections unmount.
Notes for AI
- Give items unique ids; value is the list of open ids.
Compatibility
| Runs on | Supported |
|---|---|
| Expo SDK 57 | Yes |
| Expo SDK 58 | Yes |
| React Native CLI (with Expo modules) | Yes |
| Expo Go | Yes |
| iOS | Yes |
| Android | Yes |
This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.