Skip to Content
⭐️ Leave a star →
ComponentsAccordion

Accordion

Collapsible sections. Supports single (one item open at a time) and multiple (many open at once). Controlled and uncontrolled.

Features

Can expand one or multiple items.
Full keyboard navigation.
Can be controlled or uncontrolled.
Supports animation with forceMount and CSS transitions.
Supports disabled state per item or globally.

Example

A headless component library. Zero styles shipped — you bring your own via className and data-attribute selectors.
import { Accordion } from '@wire-ui/react' <Accordion.Root type="single" collapsible defaultValue="item-1"> <Accordion.Item value="item-1"> <Accordion.Trigger>What is wire-ui?</Accordion.Trigger> <Accordion.Content> A headless component library. Zero styles shipped — you bring your own via className and data-attribute selectors. </Accordion.Content> </Accordion.Item> </Accordion.Root>

Styling

Accordion uses data-state on Item, Trigger, and Content to indicate open/closed state. Use this to style the active section, rotate chevron icons, or animate content height.

<Accordion.Trigger className=" text-black data-[state=open]:font-bold data-[disabled]:opacity-50 data-[disabled]:cursor-not-allowed "> Section title </Accordion.Trigger> <Accordion.Content className=" data-[state=closed]:hidden "> Content here </Accordion.Content>

Using data attributes

Accordion sets data-state on Item, Trigger, and Content elements. The value is "open" or "closed".

/* Rotate chevron when open */ [data-state="open"] svg { transform: rotate(180deg); } /* Animate content */ [data-state="closed"] .content { display: none; } [data-state="open"] .content { display: block; } /* Disabled trigger */ [data-disabled] { opacity: 0.5; cursor: not-allowed; }

Root props (single)

PropTypeDefaultDescription
type'single'requiredSingle selection mode
valuestringControlled open item
defaultValuestringInitial open item
onChange(value: string) => voidCalled when selection changes
collapsiblebooleanfalseAllow closing the open item by clicking it again
disabledbooleanfalseDisables all items

Root props (multiple)

PropTypeDefaultDescription
type'multiple'requiredMultiple selection mode
valuestring[]Controlled open items
defaultValuestring[][]Initial open items
onChange(value: string[]) => voidCalled when selection changes
disabledbooleanfalseDisables all items

Item props

PropTypeDescription
valuestringUnique identifier for this item
disabledbooleanDisables this specific item

Data attributes

AttributeElementValues
data-stateItem, Trigger, Content"open" / "closed"
data-disabledItem, TriggerPresent when disabled

Trigger also sets aria-expanded.

Keyboard Interactions

KeyDescription
SpaceOpens/closes the focused collapsible.
EnterOpens/closes the focused collapsible.
TabMoves focus to the next trigger.
Shift+TabMoves focus to the previous trigger.
Last updated on

MIT License © 2026 wire-ui

Accordion – Wire UI