1. Documentation
  2. Layout
  3. Accordion
ReadmenpmGitHub
  • Introduction
  • Installation
  • Theming
  • Icons
  • Accordion
  • Card
  • Scroll Area
  • Separator
  • Sidebar
  • Field
  • Label
  • Input
  • Textarea
  • Number Field
  • OTP Field
  • Select
  • Combobox
  • Checkbox
  • Radio
  • Switch
  • Slider
  • Toggle
  • Calendar
  • Date Picker
  • File Upload
  • Button
  • Copy Button
  • Dropdown
  • Command
  • Tabs
  • Breadcrumb
  • Pagination
  • Tree
  • Table
  • Data Table
  • Stat
  • Timeline
  • Avatar
  • Status Bar
  • Badge
  • Meter
  • Empty
  • Skeleton
  • Spinner
  • Toast
  • Dialog
  • Sheet
  • Popover
  • Tooltip
  • Text
  • Kbd
  • Code Block
  • Utilities
  • Design rules

Accordion

Stacked, collapsible sections — from data in one line, or composed when a row needs its own markup.

Loading documentation…

Icons< PreviousCardNext >

Powered by heyo

On this page

UsageCompose itCollapsibleHiding the chevronPropertiesAccordionAccordion.TriggerAccordion.Item and Accordion.ContentCollapsible

<Accordionitems={[  { title: "Limits", children: "100 requests per second, bursting to 300." },  { title: "Regions", children: "Frankfurt, Warsaw and Ashburn." },  { title: "Retention", children: "Logs are kept for 7 days." },]}/>

Accordion stacks sections that open one at a time. It is bounded by a hairline top and bottom and separated by one between rows — no cards, no gaps, no second background. A list of collapsible sections is a list, and a list reads best as one block.

Only one section is open at a time by default; pass multiple when the sections are independent rather than alternatives.

Usage

tsx
import { Accordion } from "@heyo-sh/heyo-ui";<Accordion items={[{ title: "Limits", children: "100 req/s" }]} />;

Compose it

Use the subcomponents when a row needs an icon, custom markup, or anything richer than a title and a body.

bun run build — 14s, cached.

<Accordion multiple defaultValue={["build"]}><Accordion.Item value="build">  <Accordion.Trigger icon={IconRocket}>Build</Accordion.Trigger>  <Accordion.Content>    <code>bun run build</code> — 14s, cached.  </Accordion.Content></Accordion.Item><Accordion.Item value="deploy">  <Accordion.Trigger icon={IconWorld}>Deploy</Accordion.Trigger>  <Accordion.Content>Rolled out to 3 regions.</Accordion.Content></Accordion.Item></Accordion>

The items shorthand and composition are interchangeable — items simply builds the same subcomponents for you.

Collapsible

One section instead of several. Accordion manages a group; Collapsible manages a single disclosure and has no chrome of its own, so it fits inside whatever you are already building.

DATABASE_URL=…
<Collapsible defaultOpen><Collapsible.Trigger render={<Button variant="outline" size="sm">Environment variables</Button>} /><Collapsible.Content>  <pre className="mt-2 text-sm text-heyo-subtle">DATABASE_URL=…</pre></Collapsible.Content></Collapsible>
Sidebar sections

The sidebar has its own collapsible wired to the rail animation — Sidebar.Collapsible. Use that one inside a menu.

Hiding the chevron

Set chevron={false} when the row already carries its own affordance — a switch, a badge, a count.

<Accordion><Accordion.Item value="webhooks">  <Accordion.Trigger chevron={false}>    Webhooks    <Badge variant="count">3</Badge>  </Accordion.Trigger>  <Accordion.Content>Three endpoints are listening.</Accordion.Content></Accordion.Item></Accordion>

Properties

Accordion

itemsAccordionItemData[]optional

Shorthand that builds every item, trigger and panel from data. Each entry takes title, children, and optionally value, icon and disabled.

multiplebooleanoptional

Allows several sections to be open at once. It defaults to false.

defaultValueValue[]optional

The sections open on first render, by value.

valueValue[]optional

The controlled open sections. Pair it with onValueChange.

onValueChange(value: Value[]) => voidoptional

Fires whenever a section opens or closes.

disabledbooleanoptional

Ignores interaction on every row.

keepMountedbooleanoptional

Keeps closed panels in the DOM. It defaults to false.

hiddenUntilFoundbooleanoptional

Lets the browser's in-page search find and expand a closed panel.

classNamestringoptional

Merged into the outer list.

Accordion.Trigger

iconIconLikeoptional

A leading glyph: a component, an element, or any node.

chevronbooleanoptional

Draws the rotating chevron. It defaults to true.

childrenReactNodeoptional

The row's content. Anything after the label is pushed to the right edge.

Accordion.Item and Accordion.Content

valueValueoptional

The item's identity, used by value and defaultValue. It falls back to the index.

disabledbooleanoptional

Locks a single row.

childrenReactNodeoptional

Accordion.Content renders the panel body and animates its own height.

Collapsible

defaultOpenbooleanoptional

Open on first render.

openbooleanoptional

The controlled state. Pair it with onOpenChange.

onOpenChange(open: boolean) => voidoptional

Fires when the section opens or closes.

renderRenderPropoptional

On Collapsible.Trigger, swaps the button for anything else — usually a Button.