---
title: Collapse
description: "`Collapse` is a component that allows you to expand or collapse an element for display."
links:
- style: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/components/collapse/collapse.style.ts
- source: https://github.com/yamada-ui/yamada-ui/tree/main/packages/react/src/components/collapse
- storybook: https://yamada-ui.github.io/yamada-ui?path=/story/components-collapse--basic
---
```tsx
const [open, { toggle }] = useBoolean()
return (
クリリンのことか……クリリンのことかーーーっ!!!!!
)
```
## Usage
```tsx
import { Collapse } from "@yamada-ui/react"
```
```tsx
import { Collapse } from "@/components/ui"
```
```tsx
import { Collapse } from "@workspaces/ui"
```
```tsx
```
### Change the Duration
To change the duration, set a number (in seconds) to `duration`.
```tsx
const [open, { toggle }] = useBoolean()
return (
クリリンのことか……クリリンのことかーーーっ!!!!!
)
```
### Unmount on Exit
To unmount the component when it is not visible, set `unmountOnExit` to `true`.
```tsx
const [open, { toggle }] = useBoolean()
return (
クリリンのことか……クリリンのことかーーーっ!!!!!
私の戦闘力は530000です。ですがもちろんフルパワーであなたと戦う気はありませんからご心配なく……
)
```
### Disable Opacity Animation
To disable the opacity animation, set `animationOpacity` to `false`.
```tsx
const [open, { toggle }] = useBoolean()
return (
クリリンのことか……クリリンのことかーーーっ!!!!!
私の戦闘力は530000です。ですがもちろんフルパワーであなたと戦う気はありませんからご心配なく……
)
```
### Add a Starting Height
To add a starting height, set a string or number to `startingHeight`.
```tsx
const [open, { toggle }] = useBoolean()
return (
私の戦闘力は530000です。
ですがもちろんフルパワーであなたと戦う気はありませんからご心配なく……
)
```
## Props
| Prop | Default | Type | Description |
| ------------------ | -------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `as` | - | `keyof IntrinsicElements` | The HTML element to render. |
| `asChild` | - | `boolean` | Merges its props onto its immediate child. |
| `css` | - | `CSSObject \| CSSObject[]` | The CSS object. |
| `colorScheme` | - | `"amber" \| "black" \| "blackAlpha" \| "blue" \| "cyan" \| "danger" \| "emerald" \| "error" \| "flashy" \| "fuchsia" ...` | Set color scheme variables. |
| `enter` | - | `any` | Custom `enter`. |
| `exit` | - | `any` | Custom `exit`. A target to animate to when this component is removed from the tree. This component **must** be the first animatable child of an `AnimatePresence` to enable this exit animation. This limitation exists because React doesn't allow components to defer unmounting until after an animation is complete. Once this limitation is fixed, the `AnimatePresence` component will be unnecessary. |
| `initial` | - | `any` | Custom `initial`. Properties, variant label or array of variant labels to start in. Set to `false` to initialise with the values in `animate` (disabling the mount animation) |
| `animationOpacity` | `true` | `boolean` | If `true`, the opacity of the content will be animated. |
| `delay` | `0` | `MotionLifecycleProps \| number` | Custom `delay` definition for `enter` and `exit`. |
| `duration` | `0.2` | `MotionLifecycleProps \| number` | Custom `duration` definition for `enter` and `exit`. |
| `endingHeight` | `"auto"` | `number \| string` | The height you want the content in its expanded state. |
| `open` | - | `boolean` | Show the component. triggers when enter or exit states. |
| `startingHeight` | `0` | `number \| string` | The height you want the content in its collapsed state. |
| `transition` | - | `MotionLifecycleProps` | Custom `transition` definition for `enter` and `exit`. |
| `transitionEnd` | - | `MotionLifecycleProps` | Custom `transitionEnd` definition for `enter` and `exit`. |
| `unmountOnExit` | - | `boolean` | If `true`, the element will unmount when `open={false}` and animation is done. |