Collapsible
An interactive component that can be expanded or collapsed.
Animation
You can use CSS animations to create smooth transitions for opening and closing the Collapsible content.
Utilize the data-state attribute in combination with the --height CSS variable to animate the open and closed states.
@keyframes slideDown {
  from { height: 0; }
  to { height: var(--height); }
}
@keyframes slideUp {
  from { height: var(--height); }
  to { height: 0; }
}
[data-scope='accordion'][data-part='item-content'][data-state='open'] {
  animation: slideDown 250ms;
}
[data-scope='accordion'][data-part='item-content'][data-state='closed'] {
  animation: slideUp 200ms;
}
Examples
Learn how to use the Collapsible component in your project. Let's examine
the most basic example:
import { Collapsible } from '@ark-ui/react'
export const Basic = () => (
  <Collapsible.Root>
    <Collapsible.Trigger>Toggle</Collapsible.Trigger>
    <Collapsible.Content>Content</Collapsible.Content>
  </Collapsible.Root>
)
import { Collapsible } from '@ark-ui/solid'
export const Basic = () => (
  <Collapsible.Root>
    <Collapsible.Trigger>Toggle</Collapsible.Trigger>
    <Collapsible.Content>Content</Collapsible.Content>
  </Collapsible.Root>
)
<script setup lang="ts">
import { Collapsible } from '@ark-ui/vue'
</script>
<template>
  <Collapsible.Root>
    <Collapsible.Trigger>Toggle</Collapsible.Trigger>
    <Collapsible.Content>Content</Collapsible.Content>
  </Collapsible.Root>
</template>
Events
You can listen for the onExitComplete event to know when the Collapsible.Content is no longer visible:
Example not foundExample not foundExample not foundLazy Mount
To delay the mounting of the Collapsible.Content, use the lazyMount prop:
Example not foundExample not foundExample not foundUnmount on Exit
To remove the Collapsible.Content from the DOM when it is not visible, use the
unmountOnExit prop:
Example not foundExample not foundExample not foundCombining Lazy Mount and Unmount on Exit
Both lazyMount and unmountOnExit can be combined to ensure that the component is
mounted only when the Collapsible is expanded and unmounted when it is collapsed:
Example not foundExample not foundExample not foundAPI Reference
Root
| Prop | Default | Type | 
|---|---|---|
asChild | booleanRender as a different element type.  | |
defaultOpen | booleanThe initial open state of the collapsible when it is first rendered. Use when you do not need to control its open state.  | |
disabled | booleanWhether the collapsible is disabled  | |
id | stringThe unique identifier of the machine.  | |
ids | Partial<{ root: string; content: string; trigger: string }>The ids of the elements in the collapsible. Useful for composition.  | |
lazyMount | false | booleanWhether to enable lazy mounting  | 
onExitComplete | () => voidFunction called when the animation ends in the closed state.  | |
onOpenChange | (details: OpenChangeDetails) => voidFunction called when the popup is opened  | |
open | booleanWhether the collapsible is open  | |
unmountOnExit | false | booleanWhether to unmount on exit.  | 
Content
| Prop | Default | Type | 
|---|---|---|
asChild | booleanRender as a different element type.  | 
Trigger
| Prop | Default | Type | 
|---|---|---|
asChild | booleanRender as a different element type.  |