Data Display
Collapse
A set of collapsible panels that can all be open simultaneously — unlike Accordion which limits to one. Supports accordion mode, ghost style, animated transitions, and extra content per panel.
Default (multiple open)
What is Benflux UI?
How is it different from shadcn/ui?
Popular
Is it accessible?
Disabled panel
Accordion mode (one open at a time)
What is Benflux UI?
How is it different from shadcn/ui?
Popular
Is it accessible?
Ghost variant (no outer border)
What is Benflux UI?
How is it different from shadcn/ui?
Popular
Is it accessible?
Installation
npx benflux-ui add collapseControlled
"use client"
const [active, setActive] = useState<string[]>(["1"])
<Collapse
activeKey={active}
onChange={setActive}
items={items}
/>Custom expand icon
import { Plus, Minus } from "lucide-react"
<Collapse
expandIcon={({ isActive }) =>
isActive ? <Minus className="h-4 w-4" /> : <Plus className="h-4 w-4" />
}
expandIconPosition="end"
items={items}
/>Props — Collapse
| Prop | Type | Default | Description |
|---|---|---|---|
| items* | CollapseItem[] | — | Array of panel definitions |
| activeKey | string | string[] | — | Controlled open panels |
| defaultActiveKey | string | string[] | [] | Initially open panels (uncontrolled) |
| onChange | (keys: string[]) => void | — | Called when panels are opened or closed |
| accordion | boolean | false | Only one panel can be open at a time |
| bordered | boolean | true | Show outer border |
| ghost | boolean | false | Transparent background, individual panel borders |
| size | "small" | "middle" | "large" | "middle" | Padding size of headers and content |
| expandIcon | ({ isActive }: { isActive: boolean }) => ReactNode | — | Custom expand icon |
| expandIconPosition | "start" | "end" | "start" | Position of the expand icon |
CollapseItem
interface CollapseItem {
key: string
label: ReactNode
children: ReactNode
extra?: ReactNode // Extra content rendered in the header (right side)
showArrow?: boolean // Show/hide the expand arrow (default: true)
collapsible?: "header" | "icon" | "disabled"
forceRender?: boolean // Keep content mounted even when collapsed
}