React Native Glow UI v1 is out now!
Logo
Components

Accordion

Accordion component for React Native.

Installation

npx rn-glow add accordion

⚙️ Props

Accordion Props

PropTypeDefaultDescription
childrenReactNodeThe content to be rendered inside the accordion container.
classNamestringOptional CSS class for the accordion root.

AccordionItem Props

PropTypeDefaultDescription
childrenReactNodeContent of a single accordion item.
isActivebooleanfalseControls whether the item is expanded.
onToggle() => voidCallback when the item is toggled.
classNamestringOptional class to style the item.

AccordionTrigger Props

PropTypeDefaultDescription
childrenReactNodeThe clickable element to trigger expand/collapse.
isActivebooleanfalseIndicates if the associated item is active.
onToggle() => voidTriggered when the item is clicked/toggled.
classNamestringOptional class to style the trigger.

AccordionContent Props

PropTypeDefaultDescription
childrenReactNodeThe content shown when the item is expanded.
isActivebooleanfalseWhether the content is visible.
classNamestringOptional class to style the content.

🚀 Example

import { View, Text, ScrollView, SafeAreaView } from "react-native";
import React from "react";
import {
  Accordion,
  AccordionContent,
  AccordionItem,
  AccordionTrigger,
} from "@/components/index";

const AccordionDemo = (): React.ReactNode => {
  return (
    <ScrollView
      className="flex-1 bg-gray-950"
      contentContainerStyle={{
        flexGrow: 1,
        paddingVertical: 24,
      }}
      scrollEnabled={true}
    >
      <SafeAreaView className="flex-1">
        <View className="px-6 mb-14 mt-5">
          <Text className="text-white text-2xl font-semibold text-center mb-2">
            Frequently Asked Questions
          </Text>
          <Text className="text-gray-400 text-center text-sm">
            Everything you need to know about our platform
          </Text>
        </View>
        <View className="mx-6">
          <Accordion className="space-y-1">
            <AccordionItem className="border border-gray-800 rounded-lg overflow-hidden">
              <AccordionTrigger className="px-6 py-4 hover:bg-gray-900/50">
                <Text className="text-white text-base font-medium">
                  How do I get started?
                </Text>
              </AccordionTrigger>
              <AccordionContent className="px-6 py-4 bg-gray-900/30 border-t border-gray-800">
                <View className="ml-3">
                  <Text className="text-gray-300 text-sm leading-6">
                    Getting started is simple. Create your account, complete
                    your profile, and explore the dashboard. Our onboarding
                    guide will walk you through the essential features to help
                    you get up and running quickly.
                  </Text>
                </View>
              </AccordionContent>
            </AccordionItem>
          </Accordion>
        </View>
      </SafeAreaView>
    </ScrollView>
  );
};

export default AccordionDemo;