Accordion
A set of collapsible panels with headings.
Anatomy
Import the component and assemble its parts:
Examples
Open multiple panels
You can set up the accordion to allow multiple panels to be open at the same time using the multiple prop.
Hidden until found
The hiddenUntilFound prop hides closed panels with hidden="until-found" so the browser can search their contents and reveal the matching panel automatically. It can be set on each Accordion.Panel, or once on Accordion.Root to apply to all panels.
To try it, press Ctrl+F (Cmd+F on macOS) and search for "restocking"—the browser opens the closed panel containing the match. When hiddenUntilFound is enabled, closed panels always remain mounted in the DOM, which also makes their contents indexable by search engines.
Older browsers that don't support hidden="until-found" keep panels hidden until their trigger opens them, and find-in-page skips over the contents.
API reference
Root
Groups all parts of the accordion. Renders a <div> element.
value unknown[] []
- Name
- Description
Values of the open items. Use
bind:valueto share the array with the parent. A value passed withoutbind:holds until the parent changes it.- Type
unknown[]- Default
[]- Binding
bind:value
disabled boolean | null false
- Name
- Description
Whether the accordion should ignore user interaction.
- Type
boolean | null- Default
false
- Name
- Description
Lets page search find a closed panel and open it. Overrides
keepMountedand useshidden="until-found".- Type
boolean- Default
false
keepMounted boolean false
- Name
- Description
Whether closed panels stay in the DOM. Ignored when
hiddenUntilFoundis set.- Type
boolean- Default
false
loopFocus boolean true
- Name
- Description
Deprecated. Arrow keys no longer move focus, so this does nothing.
- Type
boolean- Default
true
onValueChange function —
- Name
- Description
Called before the open values change. Call
eventDetails.cancel()to veto it.- Type
(value: unknown[], eventDetails: AccordionRootChangeEventDetails) => void
multiple boolean false
- Name
- Description
When false, opening one item closes the others. When true, each item changes on its own.
- Type
boolean- Default
false
orientation AccordionOrientation 'vertical'
- Name
- Description
Deprecated. It no longer moves focus.
- Type
AccordionOrientation- Default
'vertical'
render Snippet<[props: HTMLAttributes<HTMLDivElement>, state: AccordionRootState, children: Snippet | undefined]> —
- Name
- Description
Replace the default
<div>. Spreadpropsonto the host and renderchildren.- Type
Snippet<[props: HTMLAttributes<HTMLDivElement>, state: AccordionRootState, children: Snippet | undefined]>
value readonly unknown[]
- Name
value- Description
Open item values. Read it from the parent with
bind:value.- Type
readonly unknown[]
disabled boolean
- Name
disabled- Description
Whether the accordion should ignore user interaction.
- Type
boolean
orientation AccordionOrientation
- Name
orientation- Description
Orientation. It no longer moves focus. It is still exposed as
data-orientation.- Type
AccordionOrientation
data-orientation
orientation prop: vertical or horizontal.data-disabled
Item
Groups an accordion header with the corresponding panel. Renders a <div> element.
value unknown —
- Name
- Description
Identifies this item in
value. Omitted values get a generatedbase-ui-id.- Type
unknown
disabled boolean | null false
- Name
- Description
Whether this item should ignore user interaction. The root
disabledvalue also disables it.- Type
boolean | null- Default
false
onOpenChange function —
- Name
- Description
Called before this item opens or closes. Call
eventDetails.cancel()to veto it.- Type
(open: boolean, eventDetails: AccordionItemChangeEventDetails) => void
render Snippet<[props: HTMLAttributes<HTMLDivElement>, state: AccordionItemState, children: Snippet | undefined]> —
- Name
- Description
Replace the default
<div>. Spreadpropsonto the host and renderchildren.- Type
Snippet<[props: HTMLAttributes<HTMLDivElement>, state: AccordionItemState, children: Snippet | undefined]>
hidden boolean
- Name
hidden- Description
Whether the panel is currently hidden.
- Type
boolean
index number
- Name
index- Description
DOM order of the item.
-1until the item host is mounted.- Type
number
open boolean
- Name
open- Description
Whether this item is open.
- Type
boolean
value readonly unknown[]
- Name
value- Description
Open item values. Read it from the parent with
bind:value.- Type
readonly unknown[]
disabled boolean
- Name
disabled- Description
Whether the accordion should ignore user interaction.
- Type
boolean
orientation AccordionOrientation
- Name
orientation- Description
Orientation. It no longer moves focus. It is still exposed as
data-orientation.- Type
AccordionOrientation
data-open
data-closed
data-hidden
data-disabled
data-orientation
orientation prop of the root.data-index
Header
A heading that labels the corresponding panel. Renders an <h3> element.
render Snippet<[props: HTMLAttributes<HTMLHeadingElement>, state: AccordionHeaderState, children: Snippet | undefined]> —
- Name
- Description
Replace the default
<h3>. Spreadpropsonto the host and renderchildren.- Type
Snippet<[props: HTMLAttributes<HTMLHeadingElement>, state: AccordionHeaderState, children: Snippet | undefined]>
hidden boolean
- Name
hidden- Description
Whether the panel is currently hidden.
- Type
boolean
index number
- Name
index- Description
DOM order of the item.
-1until the item host is mounted.- Type
number
open boolean
- Name
open- Description
Whether this item is open.
- Type
boolean
value readonly unknown[]
- Name
value- Description
Open item values. Read it from the parent with
bind:value.- Type
readonly unknown[]
disabled boolean
- Name
disabled- Description
Whether the accordion should ignore user interaction.
- Type
boolean
orientation AccordionOrientation
- Name
orientation- Description
Orientation. It no longer moves focus. It is still exposed as
data-orientation.- Type
AccordionOrientation
data-open
data-closed
data-hidden
data-disabled
data-orientation
orientation prop of the root.data-index
Trigger
A button that opens and closes the corresponding panel. Renders a <button> element.
disabled boolean | null —
- Name
- Description
Whether the trigger should ignore user interaction.
falsedoes not re-enable a disabled item or root.- Type
boolean | null
nativeButton boolean true
- Name
- Description
Whether the host is a native
<button>. Setfalsewhenrendersupplies a non-button element.- Type
boolean- Default
true
onclick MouseEventHandler<HTMLElement> | null —
- Name
- Description
Runs before the trigger's handler. Call
event.preventDefault()to skip it.- Type
MouseEventHandler<HTMLElement> | null
render Snippet<[props: AccordionTriggerHostProps, state: AccordionTriggerState, children: Snippet | undefined]> —
- Name
- Description
Replace the default
<button>. Spreadpropsonto the host and renderchildren.- Type
Snippet<[props: AccordionTriggerHostProps, state: AccordionTriggerState, children: Snippet | undefined]>
hidden boolean
- Name
hidden- Description
Whether the panel is currently hidden.
- Type
boolean
index number
- Name
index- Description
DOM order of the item.
-1until the item host is mounted.- Type
number
open boolean
- Name
open- Description
Whether this item is open.
- Type
boolean
value readonly unknown[]
- Name
value- Description
Open item values. Read it from the parent with
bind:value.- Type
readonly unknown[]
disabled boolean
- Name
disabled- Description
Whether the accordion should ignore user interaction.
- Type
boolean
orientation AccordionOrientation
- Name
orientation- Description
Orientation. It no longer moves focus. It is still exposed as
data-orientation.- Type
AccordionOrientation
data-panel-open
data-hidden
data-disabled
data-orientation
orientation prop of the root.data-index
Panel
A collapsible panel with the accordion item contents. Renders a <div> element.
- Name
- Description
Allows page search to find and expand this panel. Overrides the root value when set.
- Type
boolean
keepMounted boolean —
- Name
- Description
Whether to keep this panel mounted while closed. Overrides the root value when set. Ignored when hidden-until-found is on.
- Type
boolean
render Snippet<[props: HTMLAttributes<HTMLDivElement>, state: AccordionPanelState, children: Snippet | undefined]> —
- Name
- Description
Replace the default
<div>. Spreadpropsonto the host and renderchildren.- Type
Snippet<[props: HTMLAttributes<HTMLDivElement>, state: AccordionPanelState, children: Snippet | undefined]>
transitionStatus TransitionStatus
- Name
transitionStatus- Description
Panel motion phase. Can settle before the item does.
- Type
TransitionStatus
hidden boolean
- Name
hidden- Description
Whether the panel is currently hidden.
- Type
boolean
index number
- Name
index- Description
DOM order of the item.
-1until the item host is mounted.- Type
number
open boolean
- Name
open- Description
Whether this item is open.
- Type
boolean
value readonly unknown[]
- Name
value- Description
Open item values. Read it from the parent with
bind:value.- Type
readonly unknown[]
disabled boolean
- Name
disabled- Description
Whether the accordion should ignore user interaction.
- Type
boolean
orientation AccordionOrientation
- Name
orientation- Description
Orientation. It no longer moves focus. It is still exposed as
data-orientation.- Type
AccordionOrientation
data-open
data-closed
data-hidden
data-disabled
data-orientation
orientation prop of the root.data-index
data-starting-style
data-ending-style
--accordion-panel-height
auto.--accordion-panel-width
auto.