Expandable card

A React component in Beamline's Layout category, in the free sample.

A dense card that grows in place when asked: the frame resizes and the clamped preview opens into the full text.

Use it for

  • Dense cards (alerts, insights) that need room for detail on request.

Not for

  • Full records (open a sheet).

Anatomy

  • card (m-surface in both states)
  • title
  • description
  • toggle (ghost icon Button, aria-expanded; only when the preview cuts something off)
  • body (owns 13px/1.6 ink-2 type; closed: previewLines lines, the last fading into the card when cut; a click on a cut preview opens it)

States

  • closed (clamped preview, faded last line)
  • closed, whole (the detail fits: no toggle, no fade)
  • open (full text, wider frame)

Keyboard

  • The toggle is a button with aria-expanded
  • Escape closes an open card and returns focus to the toggle

Motion

The frame resizes on spring.smooth (critically damped, about 300 ms) while title and body keep their position; reduced motion switches instantly. The surface role never changes between states.

Props

PropTypeDefaultDescription
title / descriptionReactNode—title: Heading shown above the content. Required. description: Supporting text beneath the label or heading. Defaults to no supporting text.
expanded / defaultExpanded / onExpandedChangeboolean—expanded: Controlled expanded state; omit to use defaultExpanded. defaultExpanded: Initial expanded state when uncontrolled; defaults to false. onExpandedChange: Reports expanded items after a change; no callback by default.
width / expandedWidthnumber320 / 520width: px wide closed and open. Default 320 / 520. expandedWidth: Width of the expanded panel in pixels. Defaults to 520.
previewLinesnumber2Lines of the preview while closed. Default 2.
classNamesExpandableCardClassNames—Classes for the named visual parts; no part overrides by default.
style / refCSSProperties / 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.
title (required)ReactNode—Heading shown above the content. Required.
descriptionReactNode—Supporting text beneath the label or heading. Defaults to no supporting text.
children (required)ReactNode—The detail: a clamped preview while closed, all of it once open.
expandedboolean—Controlled expanded state; omit to use defaultExpanded.
defaultExpandedboolean—Initial expanded state when uncontrolled; defaults to false.
onExpandedChange((expanded: boolean) => void)—Reports expanded items after a change; no callback by default.
widthnumber—px wide closed and open. Default 320 / 520.
expandedWidthnumber—Width of the expanded panel in pixels. Defaults to 520.
classNamestring—Classes on the documented visual root; no override by default.
styleCSSProperties—Inline styles on the documented visual root; no inline overrides by default.
refRef<HTMLElement>—Receives the documented root element; no ref by default.

Built from

Dependencies

lucide-react, motion

Import

import { ExpandableCard } from "@beamline/expandable-card";

Get it

Expandable card is part of Beamline UI. Install the parts you need in your React app as compiled packages or editable source. Expandable card 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…
  • Accordion: 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…
  • 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.

Compared in: Beamline UI and Kobra: interaction design and app screens

Part of Beamline UI: polished, editable React components and complete screens for custom applications. Build your own style from any look; tokens, fonts, radii, motion; not only colours.