Accordion

A stack of headings that each open to show more content, so a long page stays short.

Most orders arrive in 3 to 5 working days. Remote areas can take up to 10.
import {
  Accordion,
  AccordionItem,

When to use it

Use an accordion when people usually need only one or two of several short sections: questions and answers, the steps of a guide, the parts of an order. The headings stay in view, so people can scan them and open only what they need.

Do not hide content that nearly everyone needs, because it makes them click for nothing. For a single section that opens and closes, use a Collapsible. For views that replace each other, use Tabs.

Import

import {
  Accordion,
  AccordionItem,
  AccordionTrigger,
  AccordionPanel,
} from "@hel/ui/accordion"

Anatomy

Accordion is the frame. Each AccordionItem has a value, a AccordionTrigger that is the heading, and an AccordionPanel that is the hidden content.

<Accordion defaultValue={["shipping"]}>
  <AccordionItem value="shipping">
    <AccordionTrigger>How long does shipping take?</AccordionTrigger>
    <AccordionPanel>Most orders arrive in 3 to 5 working days.</AccordionPanel>
  </AccordionItem>
</Accordion>

The value is always a list of strings, even when only one item can be open. Up and Down move between the headings, and Home and End jump to the first and last. Space and Enter open and close the focused one.

Examples

Several open at once

By default, opening an item closes the one that was open. Add multiple to let people keep several open, which suits sections that people compare.

Visa, Mastercard and American Express. The charge is made when the order ships.
We email the bank details. Your order is held for 5 days until the payment arrives.
import {
  Accordion,
  AccordionItem,

Controlled value

Use value and onValueChange when something else needs to open or close the items, such as a "next step" button. Here the buttons set the list directly.

Use your work email.
import * as React from "react"

import {

Props

Accordion

PropTypeDefault
value / defaultValuestring[]none
onValueChange(value: string[]) => voidnone
multiplebooleanfalse
disabledbooleanfalse
keepMountedbooleanfalse
loopFocusbooleantrue

It also takes every prop of the Base UI accordion.

AccordionItem

PropTypeDefault
valuestringA generated id
disabledbooleanfalse

AccordionTrigger and AccordionPanel

AccordionTrigger takes the text of the heading as children. AccordionPanel takes the content as children, and adds its own padding.