Build faster with Premium Chakra UI Components 💎

Learn more
Skip to Content
DocsPlaygroundGuidesBlog
Sponsor

Accordion

Used to show and hide sections of related content on a page

SourceStorybookRecipeArk
Some value 2...

Setup

If you don't already have the snippet, run the following command to add the accordion snippet

npx @chakra-ui/cli snippet add accordion

The snippet includes a closed component composition for the Accordion component.

Usage

import {
  AccordionItem,
  AccordionItemContent,
  AccordionItemTrigger,
  AccordionRoot,
} from "@/components/ui/accordion"
<AccordionRoot>
  <AccordionItem>
    <AccordionItemTrigger />
    <AccordionItemContent />
  </AccordionItem>
</AccordionRoot>

Examples

Controlled

Set the accordion that shows up by default.

Expanded: second-item

Some value 2...

With Icon

Use the AccordionItemIcon to add an icon to each accordion item.

Product details

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur nec odio vel dui euismod fermentum.

Expand Multiple Items

Use the multiple prop to allow multiple items to be expanded at once.

Some value 2...

Sizes

Use the size prop to change the size of the accordion.

sm

Some value 2...

md

Some value 2...

lg

Some value 2...

Variants

Use the variant prop to change the visual style of the accordion. Values can be either outline, elevated, contained or plain.

outline

Some value 2...

subtle

Some value 2...

enclosed

Some value 2...

plain

Some value 2...

Disabled Item

Pass the disabled prop to disable an accordion item to prevent it from being expanded or collapsed.

Some value 2...

With Avatar

Here's an example of composing an accordion with an avatar.

With Subtext

Here's an example of adding a subtext to an accordion item.

With Actions

Here's an example of adding actions to an accordion item trigger.

Lorem ipsum odor amet, consectetuer adipiscing elit. Erat ultricies bibendum sociosqu sem congue maximus elementum. Facilisi amet blandit massa integer, amet sed suscipit. Sagittis donec molestie ad sem mollis sem. Duis nostra venenatis placerat; molestie mauris cras ut. Potenti nullam phasellus lobortis risus ridiculus. Vulputate himenaeos ac pulvinar primis suscipit. Morbi turpis dapibus convallis semper risus fermentum. Efficitur gravida montes malesuada sollicitudin sollicitudin neque; pulvinar mi.

Manual

Here's how to setup the accordion without using the snippet.

Some value 2...

Props

Root

PropDefaultType
collapsible false
boolean

Whether an accordion item can be closed after it has been expanded.

lazyMount false
boolean

Whether to enable lazy mounting

multiple false
boolean

Whether multple accordion items can be expanded at the same time.

orientation '\'vertical\''
'horizontal' | 'vertical'

The orientation of the accordion items.

unmountOnExit false
boolean

Whether to unmount on exit.

colorPalette 'gray'
'gray' | 'red' | 'orange' | 'yellow' | 'green' | 'teal' | 'blue' | 'cyan' | 'purple' | 'pink' | 'accent'

The color palette of the component

variant 'outline'
'outline' | 'subtle' | 'enclosed' | 'plain'

The variant of the component

size 'md'
'sm' | 'md' | 'lg'

The size of the component

asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

For more details, read our Composition guide.
defaultValue
string[]

The initial value of the accordion when it is first rendered. Use when you do not need to control the state of the accordion.

disabled
boolean

Whether the accordion items are disabled

id
string

The unique identifier of the machine.

ids
Partial<{ root: string item(value: string): string itemContent(value: string): string itemTrigger(value: string): string }>

The ids of the elements in the accordion. Useful for composition.

onFocusChange
(details: FocusChangeDetails) => void

The callback fired when the focused accordion item changes.

onValueChange
(details: ValueChangeDetails) => void

The callback fired when the state of expanded/collapsed accordion items changes.

value
string[]

The `value` of the accordion items that are currently being expanded.

Item

PropDefaultType
value *
string

The value of the accordion item.

asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

For more details, read our Composition guide.
disabled
boolean

Whether the accordion item is disabled.

Previous

Text

Next

Action Bar