Layout
Collapsible
Show and hide one section, such as advanced options. The building block of Accordion.
import { Collapsible } from '@reactloom/ui';Examples
Advanced options
asChild turns any Button into the trigger.
import { Button, Card, Collapsible, Input, Stack } from '@reactloom/ui';
import { ChevronDown } from 'lucide-react';
import { useState } from 'react';
export default function Example() {
const [open, setOpen] = useState(false);
return (
<Card style={{ width: '100%', maxWidth: 420 }}>
<Stack gap="4">
<Input label="Endpoint URL" defaultValue="https://api.acme.com" />
<Collapsible.Root open={open} onOpenChange={setOpen}>
<Collapsible.Trigger asChild>
<Button variant="link" endIcon={<ChevronDown style={{ rotate: open ? '180deg' : '0deg' }} />}>
Advanced options
</Button>
</Collapsible.Trigger>
<Collapsible.Content>
<Stack gap="3" style={{ paddingTop: 12 }}>
<Input label="Timeout (seconds)" defaultValue="30" inputMode="numeric" />
<Input label="Retry attempts" defaultValue="3" inputMode="numeric" />
</Stack>
</Collapsible.Content>
</Collapsible.Root>
</Stack>
</Card>
);
}API reference
Collapsible.Root
| Prop | Type | Default |
|---|---|---|
open / defaultOpen | boolean | — |
onOpenChange | (open: boolean) => void | — |
disabled | boolean | false |
Collapsible.Trigger
| Prop | Type | Default |
|---|---|---|
asChildUse your own button. | boolean | false |
Collapsible.Content
| Prop | Type | Default |
|---|---|---|
keepMountedKeep content in the DOM while closed (find-in-page). | boolean | true |
Accessibility
- The trigger exposes aria-expanded and aria-controls.
- Closed content is hidden from assistive technology and the tab order.
| Key | Action |
|---|---|
| Enter / Space | Toggle |
Usage guidelines
Do
- Keep the trigger text the same in both states.
Don’t
- Don’t hide required form fields.