Collapsible

An interactive component that expands/collapses to show or hide content

Setup

import { Collapsible } from '@fragments-sdk/ui';

Examples

Default

Basic collapsible with trigger and content

Loading preview...

Default Open

Collapsible that starts in the expanded state

Loading preview...

Chevron Start

Collapsible with chevron icon on the left

Loading preview...

No Chevron

Collapsible without chevron indicator

Loading preview...

Disabled

Collapsible in disabled state

Loading preview...

Multiple Sections

Multiple independent collapsible sections

Loading preview...

Props

PropTypeDefaultDescription
childrenRequirednodeNot setCollapsible.Trigger and Collapsible.Content components
defaultOpenbooleanfalseWhether the collapsible is initially open (uncontrolled)
openbooleanNot setControlled open state
onOpenChangefunctionNot setCallback when open state changes - (open: boolean) => void
disabledbooleanfalseWhether the collapsible is disabled

Usage Guidelines

When to use

  • Showing/hiding additional content on demand
  • Building accordions or expandable sections
  • Collapsible navigation sections
  • FAQ sections with expandable answers
  • Settings panels with grouped options

When not to use

  • Single item disclosure (use Accordion instead)
  • Navigation menus with complex interactions (use Menu)
  • Modal or overlay content (use Dialog or Popover)

Best practices

  • Use clear trigger labels that indicate expandable content
  • Consider defaultOpen for primary content users often need
  • Keep trigger text concise but descriptive
  • Use chevron icons consistently to indicate collapsible state
Accessibility
  • Trigger must have aria-expanded to indicate state
  • Content region needs aria-labelledby pointing to trigger
  • Keyboard: Enter/Space toggles open state
  • Focus should remain on trigger after toggle