Accordion

A collapsible content panel for organizing information in a compact space

Import

import { Accordion } from 'heroui-native';

Anatomy

<Accordion>
  <Accordion.Item>
    <Accordion.Trigger>
      ...
      <Accordion.Indicator>...</Accordion.Indicator>
    </Accordion.Trigger>
    <Accordion.Content>...</Accordion.Content>
  </Accordion.Item>
</Accordion>
  • Accordion: Main container that manages the accordion state and behavior. Controls expansion/collapse of items, supports single or multiple selection modes, and provides variant styling (default or surface).
  • Accordion.Item: Container for individual accordion items. Wraps the trigger and content, managing the expanded state for each item.
  • Accordion.Trigger: Interactive element that toggles item expansion. Built on Header and Trigger primitives.
  • Accordion.Indicator: Optional visual indicator showing expansion state. Defaults to an animated chevron icon that rotates based on item state.
  • Accordion.Content: Container for expandable content. Animated with layout transitions for smooth expand/collapse effects.

Usage

Basic Usage

The Accordion component uses compound parts to create expandable content sections.

<Accordion selectionMode="single">
  <Accordion.Item value="1">
    <Accordion.Trigger>
      ...
      <Accordion.Indicator />
    </Accordion.Trigger>
    <Accordion.Content>...</Accordion.Content>
  </Accordion.Item>
</Accordion>

Single Selection Mode

Allow only one item to be expanded at a time.

<Accordion selectionMode="single" defaultValue="2">
  <Accordion.Item value="1">
    <Accordion.Trigger>...</Accordion.Trigger>
    <Accordion.Content>...</Accordion.Content>
  </Accordion.Item>
  <Accordion.Item value="2">
    <Accordion.Trigger>...</Accordion.Trigger>
    <Accordion.Content>...</Accordion.Content>
  </Accordion.Item>
</Accordion>

Multiple Selection Mode

Allow multiple items to be expanded simultaneously.

<Accordion selectionMode="multiple" defaultValue={['1', '3']}>
  <Accordion.Item value="1">
    <Accordion.Trigger>...</Accordion.Trigger>
    <Accordion.Content>...</Accordion.Content>
  </Accordion.Item>
  <Accordion.Item value="2">
    <Accordion.Trigger>...</Accordion.Trigger>
    <Accordion.Content>...</Accordion.Content>
  </Accordion.Item>
  <Accordion.Item value="3">
    <Accordion.Trigger>...</Accordion.Trigger>
    <Accordion.Content>...</Accordion.Content>
  </Accordion.Item>
</Accordion>

Surface Variant

Apply a surface container style to the accordion.

<Accordion selectionMode="single" variant="surface">
  <Accordion.Item value="1">
    <Accordion.Trigger>
      ...
      <Accordion.Indicator />
    </Accordion.Trigger>
    <Accordion.Content>...</Accordion.Content>
  </Accordion.Item>
</Accordion>

Custom Indicator

Replace the default chevron indicator with custom content.

<Accordion selectionMode="single">
  <Accordion.Item value="1">
    <Accordion.Trigger>
      ...
      <Accordion.Indicator>
        <CustomIndicator />
      </Accordion.Indicator>
    </Accordion.Trigger>
    <Accordion.Content>...</Accordion.Content>
  </Accordion.Item>
</Accordion>

Without Dividers

Hide the dividers between accordion items.

<Accordion selectionMode="single" isDividerVisible={false}>
  <Accordion.Item value="1">
    <Accordion.Trigger>...</Accordion.Trigger>
    <Accordion.Content>...</Accordion.Content>
  </Accordion.Item>
  <Accordion.Item value="2">
    <Accordion.Trigger>...</Accordion.Trigger>
    <Accordion.Content>...</Accordion.Content>
  </Accordion.Item>
</Accordion>

With PressableFeedback

Wrap Accordion.Trigger with PressableFeedback to add custom press feedback animations.

import { Accordion, PressableFeedback } from 'heroui-native';

<Accordion selectionMode="single">
  <Accordion.Item value="1">
    <PressableFeedback
      feedbackVariant="highlight"
      animation={{
        highlight: {
          opacity: { value: [0, 0.05] },
        },
      }}
    >
      <Accordion.Trigger>
        <Text>Item Title</Text>
        <Accordion.Indicator />
      </Accordion.Trigger>
    </PressableFeedback>
    <Accordion.Content>...</Accordion.Content>
  </Accordion.Item>
</Accordion>;

Example

import { Accordion, useThemeColor } from 'heroui-native';
import { Ionicons } from '@expo/vector-icons';
import { View, Text } from 'react-native';

export default function AccordionExample() {
  const themeColorMuted = useThemeColor('muted');

  const accordionData = [
    {
      id: '1',
      title: 'How do I place an order?',
      icon: <Ionicons name="bag-outline" size={16} color={themeColorMuted} />,
      content:
        'Lorem ipsum dolor sit amet consectetur. Netus nunc mauris risus consequat. Libero placerat dignissim consectetur nisl.',
    },
    {
      id: '2',
      title: 'What payment methods do you accept?',
      icon: <Ionicons name="card-outline" size={16} color={themeColorMuted} />,
      content:
        'Lorem ipsum dolor sit amet consectetur. Netus nunc mauris risus consequat. Libero placerat dignissim consectetur nisl.',
    },
    {
      id: '3',
      title: 'How much does shipping cost?',
      icon: <Ionicons name="cube-outline" size={16} color={themeColorMuted} />,
      content:
        'Lorem ipsum dolor sit amet consectetur. Netus nunc mauris risus consequat. Libero placerat dignissim consectetur nisl.',
    },
  ];

  return (
    <Accordion selectionMode="single" variant="surface" defaultValue="2">
      {accordionData.map((item) => (
        <Accordion.Item key={item.id} value={item.id}>
          <Accordion.Trigger>
            <View className="flex-row items-center flex-1 gap-3">
              {item.icon}
              <Text className="text-foreground text-base flex-1">
                {item.title}
              </Text>
            </View>
            <Accordion.Indicator />
          </Accordion.Trigger>
          <Accordion.Content>
            <Text className="text-muted text-base/relaxed px-[25px]">
              {item.content}
            </Text>
          </Accordion.Content>
        </Accordion.Item>
      ))}
    </Accordion>
  );
}

API Reference

Accordion

proptypedefaultdescription
childrenReact.ReactNode-Children elements to be rendered inside the accordion
selectionMode'single' | 'multiple'-Whether the accordion allows single or multiple expanded items
variant'default' | 'surface''default'Visual variant of the accordion
isDividerVisiblebooleantrueWhether to display a divider at the bottom of each accordion item
defaultValuestring | string[] | undefined-Default expanded item(s) in uncontrolled mode
valuestring | string[] | undefined-Controlled expanded item(s)
isDisabledboolean-Whether all accordion items are disabled
isCollapsiblebooleantrueWhether expanded items can be collapsed
animationAccordionRootAnimation-Animation configuration for accordion
classNamestring-Additional CSS classes for the container
classNamesElementSlots<RootSlots>-Additional CSS classes for the slots
onValueChange(value: string | string[] | undefined) => void-Callback when expanded items change
...Animated.ViewPropsAnimated.ViewProps-All Reanimated Animated.View props are supported

ElementSlots<RootSlots>

proptypedescription
containerstringCustom class name for the accordion container
dividerstringCustom class name for the divider between items

AccordionRootAnimation

Animation configuration for accordion root component. Can be:

  • false or "disabled": Disable only root animations
  • "disable-all": Disable all animations including children
  • true or undefined: Use default animations
  • object: Custom animation configuration
proptypedefaultdescription
layout.valueLayoutTransitionLinearTransition
.springify()
.damping(140)
.stiffness(1600)
.mass(4)
Custom layout animation for accordion transitions

Accordion.Item

proptypedefaultdescription
childrenReact.ReactNode | ((props: AccordionItemRenderProps) => React.ReactNode)-Children elements to be rendered inside the accordion item, or a render function
valuestring-Unique value to identify this item
isDisabledboolean-Whether this specific item is disabled
classNamestring-Additional CSS classes
...Animated.ViewPropsAnimated.ViewProps-All Reanimated Animated.View props are supported

AccordionItemRenderProps

proptypedescription
isExpandedbooleanWhether the accordion item is currently expanded
valuestringUnique value identifier for this accordion item

Accordion.Trigger

proptypedefaultdescription
childrenReact.ReactNode-Children elements to be rendered inside the trigger
classNamestring-Additional CSS classes
isDisabledboolean-Whether the trigger is disabled
...PressablePropsPressableProps-All standard React Native Pressable props are supported

Accordion.Indicator

proptypedefaultdescription
childrenReact.ReactNode-Custom indicator content, if not provided defaults to animated chevron
classNamestring-Additional CSS classes
iconPropsAccordionIndicatorIconProps-Icon configuration
animationAccordionIndicatorAnimation-Animation configuration for indicator
...Animated.ViewPropsAnimated.ViewProps-All Reanimated Animated.View props are supported

AccordionIndicatorIconProps

proptypedefaultdescription
sizenumber16Size of the icon
colorstringforegroundColor of the icon

AccordionIndicatorAnimation

Animation configuration for accordion indicator component. Can be:

  • false or "disabled": Disable all animations
  • true or undefined: Use default animations
  • object: Custom animation configuration
proptypedefaultdescription
rotation.value[number, number][0, -180]Rotation values [collapsed, expanded] in degrees
rotation.springConfigWithSpringConfig{ damping: 140, stiffness: 1000, mass: 4 }Spring animation configuration for rotation

Accordion.Content

proptypedefaultdescription
childrenReact.ReactNode-Children elements to be rendered inside the content
classNamestring-Additional CSS classes
animationAccordionContentAnimation-Animation configuration for content
...ViewPropsViewProps-All standard React Native View props are supported

AccordionContentAnimation

Animation configuration for accordion content component. Can be:

  • false or "disabled": Disable all animations
  • true or undefined: Use default animations
  • object: Custom animation configuration
proptypedefaultdescription
entering.valueEntryOrExitLayoutTypeFadeIn
.duration(200)
.easing(Easing.out(Easing.ease))
Custom entering animation for content
exiting.valueEntryOrExitLayoutTypeFadeOut
.duration(200)
.easing(Easing.in(Easing.ease))
Custom exiting animation for content

Hooks

useAccordion

Hook to access the accordion root context. Must be used within an Accordion component.

import { useAccordion } from 'heroui-native';

const { value, onValueChange, selectionMode, isCollapsible, isDisabled } =
  useAccordion();

Returns

propertytypedescription
selectionMode'single' | 'multiple' | undefinedWhether the accordion allows single or multiple expanded items
value(string | undefined) | string[]Currently expanded item(s) - string for single mode, array for multiple mode
onValueChange(value: string | undefined) => void | ((value: string[]) => void)Callback function to update expanded items
isCollapsiblebooleanWhether expanded items can be collapsed
isDisabledboolean | undefinedWhether all accordion items are disabled

useAccordionItem

Hook to access the accordion item context. Must be used within an Accordion.Item component.

import { useAccordionItem } from 'heroui-native';

const { value, isExpanded, isDisabled, nativeID } = useAccordionItem();

Returns

propertytypedescription
valuestringUnique value identifier for this accordion item
isExpandedbooleanWhether the accordion item is currently expanded
isDisabledboolean | undefinedWhether this specific item is disabled
nativeIDstringNative ID used for accessibility and ARIA attributes

Special Notes

When using the Accordion component alongside other components in the same view, you should import and apply AccordionLayoutTransition to those components to ensure smooth and consistent layout animations across the entire screen.

import { Accordion, AccordionLayoutTransition } from 'heroui-native';
import Animated from 'react-native-reanimated';

<Animated.ScrollView layout={AccordionLayoutTransition}>
  <Animated.View layout={AccordionLayoutTransition}>
    {/* Other content */}
  </Animated.View>

  <Accordion>{/* Accordion items */}</Accordion>
</Animated.ScrollView>;

This ensures that when the accordion expands or collapses, all components on the screen animate with the same timing and easing, creating a cohesive user experience.

On this page