UI

Accordion

Stacked sections whose headings expand and collapse their content in place.

import { Accordion } from '@uthereal/ui/accordion'

Accordion playground

A focused set of accessible primitives, with sensible keyboard behavior and motion that respects reduced motion preferences.

Loading interactive preview…

Overview

Accordion stacks related sections divided by hairlines. Each section renders a heading button that expands and collapses its content in place, so readers scan titles and open only what they need. Use it for FAQs, grouped settings, and multi-part disclosures.

Use expandable text to clamp and reveal one block of long prose. Use tabs to switch between mutually exclusive views in the same space.

Usage

import { Accordion } from '@uthereal/ui/accordion'

export function BillingFaq() {
  return (
    <Accordion
      items={[
        {
          value: 'billing',
          title: 'How is billing calculated?',
          content: 'You pay per active seat each month.',
        },
        {
          value: 'export',
          title: 'Can I export my data?',
          content: 'Yes. Export CSV or JSON files from Settings.',
        },
      ]}
    />
  )
}

Supply sections through items for plain-text copy, or nest AccordionItem children for rich React content. Pass value and onValueChange to control which sections stay open from the host.

Examples

Multiple open sections and disabled items

By default, one section stays open at a time and collapsible lets the reader close it. Set multiple to keep several sections open together, and mark individual sections disabled to lock their state.

Name, photo and the email address others see.

Email digests and mentions.

FAQ size

Set size="lg" for page-level FAQs: 76px trigger rows with 18px headings and 16px body copy at 1.65 line height, capped at 62ch. Below 520px container width, rows tighten automatically to fit narrow columns.

You pay for active seats, prorated to the day.

Sections and state

PatternWhen to use
items propSerializable plain-text sections (line breaks preserved). Ideal for FAQs and agent configs.
AccordionItem childrenRich React content such as forms, lists, or media. Replaces items when present. Outside an Accordion, renders title and body visible.
Uncontrolled (default)Omit value. Opens defaultValue, or the first enabled section when defaultValue is omitted. Pass defaultValue={[]} to start closed.
ControlledPass value and onValueChange. The callback fires with the updated string[] of open section values in both modes.

Closed panels stay mounted in the DOM so local input state survives collapse and reopen.

import { useState } from 'react'
import { Accordion, AccordionItem } from '@uthereal/ui/accordion'

export function AccountSettings() {
  const [open, setOpen] = useState<string[]>(['profile'])

  return (
    <Accordion multiple value={open} onValueChange={setOpen}>
      <AccordionItem value="profile" title="Profile">
        <ProfileForm />
      </AccordionItem>
      <AccordionItem value="notifications" title="Notifications">
        <NotificationSettings />
      </AccordionItem>
    </Accordion>
  )
}

API reference

These serializable arguments and defaults come directly from the component schema.

ArgumentType / defaultDescription
itemsAccordionSection[]Default: []Up to 30 sections with a unique value, a title, plain-text content (line breaks kept) and an optional disabled flag. Leave it empty when AccordionItem children hold the sections.
multiplebooleanDefault: falseLet several sections be open at once. Otherwise opening one closes the other.
collapsiblebooleanDefault: trueLet the open section be closed again when only one may be open. Several open sections can always be closed.
defaultValuestring[]—Values of the sections open on first render: at most one unless multiple. Omitted, the first section opens, as in Arc; [] starts closed. Later edits do not reset an existing instance; in a composition the stored state wins.
sizemd | lgDefault: "md"md for panels and settings; lg is Arc's page-level FAQ size: 76px rows, 18px questions and 16px answers at prose leading.
headingLevelintegerDefault: 3Heading level (2 to 6) of each section title, so the sections fit the page outline.
recipestudio | softDefault: "studio"Visual treatment. Both recipes use the same interaction behavior.
themeAccordionTheme—Color mode, accent, and tokens for colors, type and the trigger control scale. See Theming.
motionnone | subtle | expressiveDefault: "subtle"Open and close animation preset. System reduced-motion preferences take precedence.
motionOptionsAccordionMotionOptions—The open and close transition: a tween with a duration (ms) or a spring.
dirltr | rtl—Reading direction. Omit it to inherit the page direction.

AccordionSection is { value, title, content, disabled? }. AccordionItem accepts { value, title, disabled? } plus standard div props and renders children inside the panel.

React integration

PropPurpose
value, onValueChangeControl open section values (string[]); onValueChange fires in both modes.
childrenAccordionItem elements; replaces items when provided.
renderIcon(name, context)Replace the indicator icon (context carries size and slot: 'indicator').
presetApplication defaults overridden by explicit instance props.
tokensCSS custom properties (--ui-*) applied after the typed theme.
ref, className, styleApplied to the root <div>.
Native attributesStandard div attributes (id, aria-*, data-*) forwarded to the root.

Keyboard & accessibility

KeyInteraction
TabMove focus to the next trigger or into open panel content.
Enter, SpaceToggle the focused section open or closed.
ArrowDown, ArrowUpMove focus to the next or previous enabled trigger.
Home, EndMove focus to the first or last enabled trigger.

Each trigger sits inside a native heading (h3 by default, configurable via headingLevel 2–6) with aria-expanded and aria-controls. Each panel is a labelled region (aria-labelledby). When collapsed, the panel transitions to visibility: hidden, removing it from the tab order and accessibility tree while preserving mounted state. Logical CSS properties adapt borders, padding, and alignment automatically in dir="rtl". Under forced-colors: active, focus rings use Highlight and disabled triggers use GrayText.

Motion and theming

Opening springs panel height from 0 to auto on Arc's non-overshooting smooth spring (0.4s, bounce 0) while opacity fades in over 240ms and inner content settles down out of a 2px blur. Closing reverses height on the smooth spring with a 160ms fade. The 17px chevron rotates 180deg on Arc's snappy spring (0.26s, bounce 0.12). Toggling mid-flight retargets from the current position instead of restarting.

Motion settingPanel height and content revealChevron and hover colors
subtle (default)Smooth spring height; 240ms fade in / 160ms out; 6px settle, 2px blur.Snappy spring rotation; smooth color transition.
expressiveSmooth spring height; 240ms fade in / 160ms out; 8px settle, 2px blur.Snappy spring rotation; smooth color transition.
prefers-reduced-motion: reduceImmediate (0ms) height and opacity end states; no blur or vertical drift.Immediate (0ms) turn; hover transitions off.
noneImmediate (0ms) height and opacity end states; no blur or vertical drift.Immediate (0ms) turn; hover transitions off.

Use motionOptions.transition to override the open and close transition with a custom tween (duration in milliseconds) or spring.

theme accepts mode, accent, and tokens from the core group (colors, borders, focus ring, disabled opacity, typography) and the control group (trigger height scale and icon size). An application-wide UtherealProvider supplies defaults.

Composition

In an agent composition, Accordion is a container that accepts up to 30 AccordionItem children, and AccordionItem may only sit inside an Accordion. Provide sections through items or AccordionItem children, never both; defaultValue must name existing sections. The host persists open section values at /components/instance-<id>/value, reconciling stored values across live edits. See Building with agents.

{
  "type": "Accordion",
  "props": { "defaultValue": ["profile"] },
  "children": ["profile", "notifications"]
}

On this page