Hyunsui
Docs
Collapse
A headless collapsible primitive that mirrors Radix’s Root / Trigger / Content structure while exposing data attributes and CSS variables for complete animation control.
Anatomy
Import only the parts you need and compose them freely.
API Reference
Root
Provides controlled/uncontrolled open state, handles disabled logic, and wires the ARIA relationships between trigger and content.
PropTypeDefault
open
boolean-
defaultOpen
booleanfalse
onOpenChange
function-
disabled
booleanfalse
triggerId
stringauto
contentId
stringauto
Data AttributeValue
data-state
"open" | "closed"
data-disabled
""
Trigger
The interactive button tied to the root. Automatically exposes data-state, data-disabled, and aria-expanded.
PropTypeDefault
type
stringbutton
disabled
boolean-
onClick
React.MouseEventHandler<HTMLButtonElement>-
Data AttributeValue
data-state
"open" | "closed"
data-disabled
""
Content
Measured surface that can stay mounted via forceMount and exposes --collapse-content-height / --collapse-content-width for transitions.
PropTypeDefault
forceMount
booleanfalse
Data AttributeValue
data-state
"open" | "closed"
data-disabled
""
CSS VariableDescription
--collapse-content-widthThe width of the content when it opens/closes.
--collapse-content-heightThe height of the content when it opens/closes.
Example
Animating content size
Use --collapse-content-height / --collapse-content-width to animate the size of the content.