React asChild composition, or native marker attributes.
ARIA, data attributes, and keyboard behavior from shared primitive logic.
CSS transitions.
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 Collapsible from '@milkui/react/collapsible';
<Collapsible.Root>
<Collapsible.Trigger />
<Collapsible.Content />
</Collapsible.Root>
API reference
Collapsible.Root
Prop
Type
Default
Description
defaultOpen
boolean
false
Initial uncontrolled open state.
open
boolean
undefined
Controlled open state.
onOpenChange
(open: boolean) => void
undefined
State change request callback.
disabled
boolean
false
Prevents trigger activation.
asChild
boolean
false
Render onto the child element.
Collapsible.Trigger
Prop
Type
Default
Description
disabled
boolean
false
Disables only this trigger.
href
string
Content fragment
Link to the content before enhancement.
asChild
boolean
false
Render onto the child element.
Collapsible.Content
Prop
Type
Default
Description
asChild
boolean
false
Render onto the child element.
Data attribute
Values
[data-open]
Present when open; absent when closed
[data-disabled]
Present when disabled
[mlk-collapsible-root]
Root marker
[mlk-collapsible-trigger]
Trigger marker
[mlk-collapsible-content]
Content marker
CSS variable
Description
--mlk-collapsible-content-width
Measured content width.
--mlk-collapsible-content-height
Measured content height.
Examples
Controlled
The primitive requests changes. Your state decides whether to accept them.