Vertical or horizontal orientation with direction support.
Anatomy
Triggers link to content marked hidden="until-found" before JavaScript. Following a link reveals that panel without resetting others. Enhancement adds toggle and keyboard behavior.
React anatomy
import * as Accordion from '@milkui/react/accordion';
<Accordion.Root>
<Accordion.Item>
<Accordion.Header>
<Accordion.Trigger />
</Accordion.Header>
<Accordion.Content />
</Accordion.Item>
</Accordion.Root>
API reference
Accordion.Root
Prop
Type
Default
Description
type
"single" | "multiple"
"single"
Selection mode.
value
string | string[]
undefined
Controlled value.
defaultValue
string | string[]
undefined
Initial uncontrolled value.
onValueChange
(value) => void
undefined
Value change request callback.
collapsible
boolean
false
Allow the open single item to close.
disabled
boolean
false
Disable every item.
orientation
"vertical" | "horizontal"
"vertical"
Keyboard orientation.
dir
"ltr" | "rtl"
"ltr"
Direction for horizontal navigation.
asChild
boolean
false
Render onto the child element.
Accordion.Item
Prop
Type
Default
Description
value
string
Generated identifier
Selection value; independent of the generated DOM ID.
disabled
boolean
false
Disable this item.
asChild
boolean
false
Render onto the child element.
Accordion.Header
Prop
Type
Default
Description
asChild
boolean
false
Heading wrapper for the trigger.
Accordion.Trigger
Prop
Type
Default
Description
asChild
boolean
false
Link enhanced with disclosure behavior.
Accordion.Content
Prop
Type
Default
Description
asChild
boolean
false
Render onto the child element.
Data attribute
Values
[data-open]
Present when the item is open
[data-disabled]
Present when disabled
[mlk-accordion-root]
Root marker
[mlk-accordion-item]
Item marker
[mlk-accordion-header]
Header marker
[mlk-accordion-trigger]
Trigger marker
[mlk-accordion-content]
Content marker
CSS variable
Description
--mlk-accordion-content-width
Measured content width.
--mlk-accordion-content-height
Measured content height.
Examples
Independent accordions
Disable JavaScript and reload, then open Returns and Privacy. Both remain visible. Links reveal panels without closing others. Enhancement adds independent single-selection toggling.