React

Accordion

A component that lists multiple related content sections vertically, allowing users to explore information by expanding or collapsing each section.

Available since@seed-design/react@2.0.0, @seed-design/css@2.0.0

Installation

npx @seed-design/cli@latest add ui:accordion

Props

Accordion

Prop

Type

values?string[] | undefined
defaultValues?string[] | undefined
onValuesChange?((values: string[]) => void) | undefined
disabled?boolean | undefined
multiple?boolean | undefined

AccordionItem

Prop

Type

valuestring
disabled?boolean | undefined

AccordionTrigger

Prop

Type

titleReact.ReactNode
description?React.ReactNode
prefix?React.ReactNode
suffixIcon?React.ReactNode
headingLevel?1 | 2 | 3 | 4 | 5 | 6 | undefined

AccordionContent

Prop

Type

Examples

Inline Variant

This is the default variant. Items are provided in a continuous flow, with dividers displayed between items.

Separated

When using variant="separated", each item is displayed as a separate card.

Multiple

By default, only one item can be expanded at a time. With the multiple prop, multiple items can be expanded simultaneously.

Always one open

By using the controlled pattern with values and onValuesChange, you can force always having one item open by adding a guard that prevents calling the setter when an empty array is provided.

Size

Set the size of the Accordion with size. (default: medium)

responsive is a value where the size is automatically switched according to screen width. Use size=responsive to support multiple screen widths together in products.

Prefix

You can pass prefix elements like icons to the prefix prop.

Description

You can add additional descriptions to the trigger using the description prop.

Disabled

You can disable all or individual items using the disabled prop.

  • Setting disabled on Accordion disables all items.
  • Setting disabled on AccordionItem disables only that item.

Controlled

You can directly control the open state using values and onValuesChange.

Value Array Changes

In controlled mode, the currently open items are passed as a values array. The example below shows the latest values and recent onValuesChange results each time a trigger is clicked.

Default Expanded

You can specify the initial open state using defaultValues.

Custom Content

AccordionContent acts only as an open/close animation container. It does not provide default padding, background color, border, or typography styles, so you must configure them directly in the inner content. The pattern of explicitly providing padding and background with Box, as shown in the example below, is recommended.

Accessibility

Follows the WAI-ARIA Accordion Pattern.

AccordionTrigger internally creates a heading > button structure. The default heading level is h3, and if a different level is needed to match the document structure, it can be adjusted using the headingLevel prop. The WAI-ARIA APG example also uses h3 to match the upper section structure.

Heading Level Escape Hatch

If a parent section heading already exists, please align the accordion header level using headingLevel. For example, if an accordion is placed inside an h3 section, you can maintain the document outline by lowering each item header to h4.

Keyboard Interactions

KeyAction
Enter / SpaceExpands or collapses the panel of the focused trigger.
TabMoves to the next focusable element.
Shift + TabMoves to the previous focusable element.
ArrowDownMoves focus to the next trigger. Cycles to the first if at the end.
ArrowUpMoves focus to the previous trigger. Cycles to the last if at the beginning.
HomeMoves focus to the first trigger.
EndMoves focus to the last trigger.

Table of contents