Usage
Reusable hook that encapsulates the collapsible state machine. Supports three modes: group-controlled (inside XDSCollapsibleGroup), controlled (isOpen + onOpenChange), and uncontrolled (self-managed with defaultIsOpen). Used internally by XDSCard and XDSSection.import {useXDSCollapsible} from '@xds/core/Collapsible'
Best practices
|
| Do | Use the hook directly when building custom collapsible components that need XDS collapsible behavior without XDSCollapsible wrapper. |
| Do | For accordion behavior, wrap items in XDSCollapsibleGroup and pass unique value props. |
| Don't | Implement your own open/close state when useXDSCollapsible already provides it — the hook handles group coordination automatically. |