Skip to content

Accordion

Accordion Primitive

Text Component

Demo


A vertically stacked set of interactive headings that each reveal a section of content.

Installation

Terminal window
npx @react-native-reusables/cli@latest add accordion

Usage

import {
Accordion,
AccordionContent,
AccordionItem,
AccordionTrigger,
} from '~/components/ui/accordion';
import { Text } from '~/components/ui/text';
function Example() {
return (
<Accordion
type='multiple'
collapsible
defaultValue={['item-1']}
className='w-full max-w-sm native:max-w-md'
>
<AccordionItem value='item-1'>
<AccordionTrigger>
<Text>Is it accessible?</Text>
</AccordionTrigger>
<AccordionContent>
<Text>Yes. It adheres to the WAI-ARIA design pattern.</Text>
</AccordionContent>
</AccordionItem>
<AccordionItem value='item-2'>
<AccordionTrigger>
<Text>What are universal components?</Text>
</AccordionTrigger>
<AccordionContent>
<Text>
In the world of React Native, universal components are components that work on both
web and native platforms.
</Text>
</AccordionContent>
</AccordionItem>
</Accordion>
);
}

Props

Accordion

Extends View props

PropTypeNote
type*‘single’ | ‘multiple’
asChildboolean(optional)
defaultValue(string | undefined) | string[](optional)
value(string | undefined) | string[](optional)
onValueChange((string | undefined) => void) | ((string[]) => void)(optional)
dir’ltr’ | ‘rtl’Web only (optional)
orientation’vertical’ | ‘horizontal’Web only (optional)

AccordionItem

Extends View props

PropTypeNote
asChildboolean(optional)
valuestring(optional)
disabledboolean(optional)

AccordionTrigger

Extends Pressable props

PropTypeNote
asChildboolean(optional)

AccordionContent

Extends View props

PropTypeNote
asChildboolean(optional)
forceMounttrue | undefined(optional)