Skip to main content

NeoPopAccordion

A collapsible accordion with a NeoPop 3D header, animated chevron, height-animated body, and support for both controlled and uncontrolled modes.

Usage

// dark mode example
import { NeoPopAccordion } from 'neopop-rn';
import { Text } from 'react-native';

<NeoPopAccordion
title="Payment Details"
defaultExpanded={false}
colorMode="dark"
colorConfig={{
headerBackground: '#1a1a1a',
headerTextColor: '#ffffff',
chevronColor: '#ffffff',
bodyBackground: '#0d0d0d',
edgeColor: '#3D3D3D',
}}
>
<Text style={{ color: '#ffffff' }}>Card ending in 4242</Text>
</NeoPopAccordion>
// light mode example — controlled mode
import { NeoPopAccordion } from 'neopop-rn';
import { useState } from 'react';
import { Text } from 'react-native';

function Example() {
const [expanded, setExpanded] = useState(false);

return (
<NeoPopAccordion
title="Frequently Asked Questions"
isExpanded={expanded}
onToggle={setExpanded}
colorMode="light"
rightElement={<Text style={{ fontSize: 12 }}>Details</Text>}
>
<Text>Answer to the FAQ goes here.</Text>
</NeoPopAccordion>
);
}

Props

PropTypeDefaultDescription
titlestringRequired. Text displayed in the header row.
childrenReactNodeRequired. Body content shown when expanded.
isExpandedbooleanControlled expansion state. When provided, defaultExpanded is ignored.
onToggle(next: boolean) => voidCalled with the new boolean state when the header is pressed.
defaultExpandedbooleanInitial expansion state for uncontrolled usage.
colorConfigNeoPopAccordionColorConfigPer-token color overrides (see colorConfig table).
colorMode'dark' | 'light'Theme mode for default colors.
styleStyleProp<ViewStyle>Additional style applied to the outer container.
headerStyleStyleProp<ViewStyle>Additional style applied to the header row.
titleStyleStyleProp<TextStyle>Additional style applied to the header title text.
bodyStyleStyleProp<ViewStyle>Additional style applied to the body container.
rightElementReactNodeOptional element rendered to the right of the title in the header.

colorConfig

KeyDescription
headerBackgroundBackground color of the header row.
headerTextColorColor of the title text.
chevronColorColor of the expand/collapse chevron icon.
bodyBackgroundBackground color of the body container.
edgeColorColor of the 3D border/edge on the header.

Notes

  • When isExpanded is supplied, the component is in controlled mode; you must update the prop via onToggle for the accordion to open/close.
  • When neither isExpanded nor defaultExpanded is provided, the accordion starts collapsed.
  • The body height is animated using react-native-reanimated; avoid placing children with dynamic heights that change after mount, as the initial measurement determines the animated range.
  • The chevron rotates 180° when expanded (pointing up) and returns to 0° when collapsed (pointing down).