SwipeUI

Accordion

In-flow disclosure with explicit expanded state and no hidden focusable children.

npx @swipeui/cli add accordion
Variant
Preset
Material
Scheme
Feel
Real free component with a browser animation bridge. Native motion, haptics and materials need a device.

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.tsx and 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 install so versions match your SDK.

Usage

app/help.tsx
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

PropTypeDefaultDescription
surface?"filled" | "plain" | "raised"'raised'

Group treatment.

indicator?"chevron" | "none" | "plus"'chevron'

Drawn disclosure indicator.

animateContent?booleantrue

Animate disclosure size changes.

animateIndicator?booleantrue

Animate the disclosure indicator.

itemsreadonly AccordionItem[]—

Sections in reading order.

value?readonly string[]—

Controlled expanded identifiers.

defaultValue?readonly string[][]

Initial expanded identifiers.

onValueChange?((value: readonly string[]) => void)—

Reports disclosure intent.

multiple?booleanfalse

Allow more than one expanded section.

disabled?boolean—

Prevent all changes.

haptics?booleantrue

Press feedback.

motion?MotionOverride—

Shared press/layout character.

className?string—

Root classes.

style?StyleProp<ViewStyle>—

Root layout escape hatch.

testID?string—

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, press and select motion roles, so it follows your app's feel. Pass motion to 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 onSupported
Expo SDK 57Yes
Expo SDK 58Yes
React Native CLI (with Expo modules)Yes
Expo GoYes
iOSYes
AndroidYes

This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.

Related items