A component that expands or collapses to show or hide content.
Lorem ipsum dolor sit amet consectetur adipisicing elit. Voluptatibus odit
optio, eaque laborum nesciunt dolores temporibus accusantium neque quasi
dolore, id itaque architecto libero voluptatem laboriosam soluta nobis
consectetur earum?
Usage
<script> import {Collapsible} from 'ui-ingredients';</script><Collapsible.Root> <Collapsible.Trigger>Toggle</Collapsible.Trigger> <Collapsible.Content>Content</Collapsible.Content></Collapsible.Root>
API Reference
Root
Prop
Default
Description
animateOnMount
true
booleanWhether to run the enter animation when the component mounts.
collapsedHeight
string | numberThe height of the content when collapsed.
collapsedWidth
string | numberThe width of the content when collapsed.
defaultOpen
booleanThe initial open state of the collapsible when rendered.
Use when you don't need to control the open state of the collapsible.
disabled
booleanWhether the collapsible is disabled.
id
stringThe unique identifier of the machine.
ids
{
root?: string;
content?: string;
trigger?: string;
}The ids of the elements in the collapsible. Useful for composition.
keepMounted
true
booleanWhether to keep the component mounted after exit.
lazyMount
false
booleanWhether to enable lazy mounting.
onExitComplete
() => voidCallback that fires when the exit animation of the dialog completes.
onOpenChange
(details: OpenChangeDetails) => voidThe callback invoked when the open state changes.
open
booleanThe controlled open state of the collapsible.
asChild
SnippetRender a different element.
Data Attribute
Value
data-part
root
data-scope
collapsible
data-state
"open" | "closed"
Content
Prop
Default
Description
asChild
SnippetRender a different element.
Data Attribute
Value
data-collapsible
data-disabled
Present when disabled
data-has-collapsed-size
Present when the content has collapsed width or height