Accordion
A React component in Beamline's Layout category, in the free sample.
Topics that open in place, one at a time or several: FAQs and settings sections; each header is a button (with an optional fact at its end), and the panel's height follows its content and can be reversed mid-way.
Use it for
- FAQs and settings sections where people open one topic at a time.
Not for
- A single show-more region (collapsible).
- Content people need to compare side by side.
Anatomy
- root (a size container)
- item
- header (h3) with trigger: title, meta (optional), chevron
- panel (height follows the content; reversible)
Variants
- size: md, lg
- multiple: false, true
States
- closed
- open
- opening / closing (reversible mid-way)
- disabled
- Uncontrolled open panels keep their stable item ids when items are reordered.
Keyboard
- Enter / Space toggles
- ↑ ↓ between headers
- Home / End
Motion
The panel is a one-row grid going 0fr → 1fr: it opens over --pui-duration-standard and closes over --pui-motion-out, and a reversal mid-way turns back from where it is; the words fade in a beat behind the height and leave first. The chevron turns over --pui-duration-standard and brightens on hover at once, dimming over --pui-motion-out. Reduced motion is instant.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
items | { id?, title, meta?, content, disabled? }[] | — | Items rendered in the component. Required. |
defaultOpen | number | number[] | — | Initial open item index or indices; defaults to no open panels. |
multiple | boolean | false | Let several sections stay open. Default false: opening one closes the other. |
size | "md" | "lg" | "md" | md for settings and side panels, lg for FAQ pages. |
classNames | AccordionClassNames | — | Classes for the named visual parts; no part overrides by default. |
style / ref | CSSProperties / native Ref | — | style: Inline styles on the documented visual root; no inline overrides by default. ref: Receives the documented root element; no ref by default. |
open | number | number[] | null | — | Controlled open item index, or indices with multiple; null closes the single panel. Omitted by default. |
onOpenChange | (open: number | number[] | null) => void | — | Reports the open index or null in single mode, or indices in multiple mode; no callback by default. |
className | string | — | Classes on the documented visual root; no override by default. |
style | CSSProperties | — | Inline styles on the documented visual root; no inline overrides by default. |
ref | Ref<HTMLDivElement> | — | Receives the documented root element; no ref by default. |
Dependencies
@radix-ui/react-accordion, lucide-react
Import
import { Accordion } from "@beamline/accordion";
Get it
Accordion is part of Beamline UI. Install the parts you need in your React app as compiled packages or editable source. Accordion is included in the free MIT sample. Get Beamline · Connect your agent
More in Layout
- Bezel: A double-bezel frame: an outer shell with a hairline, a small gap, and an inset panel with its own edge, so a preview, chart or media reads as set into…
- Carousel: A row of slides that snap into place: swipe on touch, drag or the arrows with a mouse, ← → when focused, or the dots; optional autoplay that pauses and…
- Card: A record or a small group of related content and actions: optional media, avatar, title, status, action, meta, free content and a Details toggle; plain…
- Resizable panels: Panes that trade space across draggable dividers; each divider is a focusable separator with arrow keys, limits, folding for collapsible panes and…
- UI root: Makes a region of any app a Beamline root: theme, brand and direction for everything inside, and a matching layer at page level where its menus, dialogs…
- Expandable card: A dense card that grows in place when asked: the frame resizes and the clamped preview opens into the full text.
- Collapsible: One region that opens and closes in place from its trigger, its height animating to the content.
- Scroll area: A native scroll region with thin overlay thumbs and edge fades that show only where more content waits; thumbs can be dragged or clicked.
- Aspect ratio: Holds media, video and embeds at a fixed width-to-height ratio while the layout resizes.
- Direction: Sets left-to-right or right-to-left for everything inside: text and logical spacing flip, and Radix parts read the direction for keys and placement.
- Separator: A hairline between groups, horizontal or vertical; hidden from screen readers unless it carries meaning.