Accordion

Accordion is an animated accordion component for React Native and React, from the dissolve library. Expandable sections: the height glides open, the chevron turns over and the content slides in.

Expandable sections on hairline dividers. Tap a header and its section opens on a smooth height curve while the chevron turns over, then the content fades in and slides down into place, a beat behind the height. One section open at a time (type single, the default, collapsible unless you say otherwise) or any number (type multiple), controlled or not. On the web each header is a button with aria-expanded and aria-controls, each section a region labelled by its header, and Arrow Up, Arrow Down, Home and End move between headers; on iOS the headers announce their expanded state and closed sections are hidden from VoiceOver. A selection tick on every change. Reduced motion: the section opens at once and the content simply fades.

Install

React Native

Install the engine once per app and wrap the root layout in <DissolveProvider> (see Installation), then copy the component into components/dissolve:

npx expo install dissolve-ui @shopify/react-native-skia react-native-reanimated react-native-worklets react-native-gesture-handler expo-haptics
npx dissolve-ui add accordion --native
npx shadcn@latest add https://dissolve.rselmi.com/r/native/accordion.json

React

Needs React 19 and react-dom, nothing else: no engine, no provider, no Tailwind. Works in the Next.js App Router.

npx dissolve-ui add accordion --web
npx shadcn@latest add https://dissolve.rselmi.com/r/accordion.json

Usage

Accordion.tsx (React Native)
import { Accordion } from '@/components/dissolve/accordion';

<Accordion
  items={[
    { value: 'shipping', title: 'Shipping', content: 'Orders leave the studio within two days.' },
    { value: 'returns', title: 'Returns', content: <ReturnsPolicy /> },
  ]}
  defaultValue={['shipping']}
/>

// Any number open, controlled.
const [open, setOpen] = useState<string[]>([]);
<Accordion type="multiple" items={faq} value={open} onValueChange={setOpen} />
Accordion.tsx (React)
import { Accordion } from '@/components/dissolve/accordion';

<Accordion
  items={[
    { value: 'shipping', title: 'Shipping', content: 'Orders leave the studio within two days.' },
    { value: 'returns', title: 'Returns', content: <ReturnsPolicy /> },
  ]}
  defaultValue={['shipping']}
/>

// Any number open, controlled.
const [open, setOpen] = useState<string[]>([]);
<Accordion type="multiple" items={faq} value={open} onValueChange={setOpen} />

Props

PropTypeDefaultDescription
items{ value, title, content, disabled? }[]The sections. content is any node; a string is set in the muted body style.
type'single' | 'multiple''single'Single: opening a section closes the other. Multiple: each opens on its own.
collapsiblebooleantrueIn single mode, the open section can be closed again.
valuestring[]Open sections (controlled). In single mode, at most one.
defaultValuestring[][]Initially open sections when uncontrolled.
onValueChange(value: string[]) => voidCalled with the open sections on every change.
hapticsbooleantrueSelection tick on every change.
classNamestringOuter classes (margins, padding, background...).

Source

Previous: ElasticSlider · Next: CopyButton · All components

dissolve is MIT licensed. Source on GitHub, package on npm. This page as markdown. For AI agents: llms.txt.