suiss/uim · React Native Component

Accordion

A vertical stack of headings that each expand to reveal a section of content.

Accordion is an open-source mobile component from suiss/uim for React Native and Expo, with SwiftUI and Jetpack Compose versions built from the same design tokens. The @esuiss/uim CLI copies its source into your project, so you own the code.

iOS
Accordion (open by default) on iOS in light mode

Accordion groups AccordionItems, each with an AccordionTrigger and an AccordionContent panel. The root and items are Reanimated views with a layout transition, so items below move smoothly as a panel opens or closes, and the trigger's caret rotates as it opens.

The default variant draws items on the page background separated by hairlines. The filled variant puts the whole list on a rounded secondary surface, which suits grouped settings or FAQ cards.

Installation

$ pnpm dlx @esuiss/uim@latest add accordion

The CLI also adds what it builds on: Icon, Text.

Manual

  1. Install the dependencies:
npx expo install class-variance-authority cn phosphor-react-native react-native-reanimated react-native-svg react-native-worklets
  1. Add the pieces it builds on: Icon, Text, and the primitives components/primitives/accordion.tsx, components/primitives/use-render.tsx.

  2. Copy the source into components/ui/accordion.tsx:

uniwind/components/ui/accordion.tsx
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
import { CaretDownIcon } from "phosphor-react-native"
import * as React from "react"
import type { GestureResponderEvent } from "react-native"
import Animated, {
  FadeOutUp,
  LayoutAnimationConfig,
  LinearTransition,
  ReduceMotion,
  useAnimatedStyle,
  useDerivedValue,
  withTiming,
} from "react-native-reanimated"
import * as AccordionPrimitive from "@/components/primitives/accordion"
import { resolveClassName } from "@/components/primitives/use-render"
  1. Update the import paths to match your project.

Usage

import { Accordion, AccordionItem, AccordionTrigger, AccordionContent } from "@/components/ui/accordion"
<Accordion defaultValue={["item-2"]}>
  <AccordionItems />
</Accordion>

Give each AccordionItem a value. By default only one item is open at a time; set multiple to let several stay open.

Use defaultValue (an array of item values) for uncontrolled state, or value with onValueChange to control it. Set disabled on the root or on a single item to block toggling, and keepMounted to keep closed panels mounted.

accordionVariants is also exported if you need the classes elsewhere.

Examples

Default

iOS
Accordion on iOS in light mode

Filled

The filled variant on a rounded secondary surface.

iOS
Accordion (filled) on iOS in light mode

Multiple

A controlled accordion with multiple, so several items stay open.

iOS
Accordion (multiple) on iOS in light mode

API Reference

Accordion

Root that holds the open state and lays out the items.

ExtendsReact.ComponentProps<typeof AccordionPrimitive.Root>
PropType
About
default or filled.
Type
"default""filled"
Default
"default"

AccordionItem

One section, separated from the previous one by a hairline.

ExtendsReact.ComponentProps<typeof AccordionPrimitive.Item>

AccordionTrigger

Pressable heading row with a rotating caret.

ExtendsReact.ComponentProps<typeof AccordionPrimitive.Trigger>

AccordionContent

Panel shown while the item is open; fades out upward on close.

ExtendsReact.ComponentProps<typeof AccordionPrimitive.Panel>
PropType
Type
string
Default
—

Accessibility

  • The header row has the header role, and the trigger has the button role with expanded and disabled accessibility state.
  • Closed panels are hidden from VoiceOver and TalkBack.
  • A disabled trigger uses a dimmed label color.

Notes

  • The trigger label underlines while pressed.
  • Animations respect the system Reduce Motion setting.
  • Uses bg-surface-secondary, border-separator and text-label tokens; light and dark follow the system appearance.