ExpoStartup

Expandable

A collapsible container component with smooth animations.

Expandable

A component that provides a collapsible container with smooth animations for showing or hiding content.

Import

import Expandable from '@/components/Expandable';

Features

  • Smooth expand/collapse animations
  • Customizable header with title and optional icon
  • Controlled or uncontrolled usage
  • Custom styling options

Props

PropTypeDefaultDescription
titlestringText displayed in the header
titleComponentReactNodeCustom component to replace the title
defaultOpenbooleanfalseInitial expanded state (uncontrolled)
openbooleanControlled expanded state
onOpenChange(open: boolean) => voidCallback when expanded state changes
headerClassNamestringAdditional classes for header
contentClassNamestringAdditional classes for content
childrenReactNodeContent to show when expanded
headerIconIconNameIcon to show next to title

Basic Usage

// Basic expandable section
<Expandable title="Frequently Asked Questions">
  <Text>This content will be shown when expanded.</Text>
</Expandable>
 
// Initially expanded
<Expandable title="Details" defaultOpen>
  <Text>This section starts expanded.</Text>
</Expandable>
 
// Controlled expandable
<Expandable 
  title="Settings" 
  open={isOpen} 
  onOpenChange={setIsOpen}
>
  <Text>Toggle controlled externally</Text>
</Expandable>

With Icon

<Expandable
  icon="CreditCard"
  title="Payment Methods"
  description="Manage your payment options"
>
  <View className="space-y-4 pt-2">
    {/* Payment method options */}
  </View>
</Expandable>

Controlled Mode

import React, { useState } from 'react';
 
function ControlledExpandable() {
  const [expanded, setExpanded] = useState(false);
  
  return (
    <Expandable
      title="Advanced Settings"
      expanded={expanded}
      onPress={() => setExpanded(!expanded)}
    >
      {/* Content */}
    </Expandable>
  );
}

On this page