Skip to Content
文档

可折叠

用于展开和折叠其他内容。

SourceStorybookRecipeArk

用法

¥Usage

import { Collapsible } from "@chakra-ui/react"
<Collapsible.Root>
  <Collapsible.Trigger />
  <Collapsible.Content />
</Collapsible.Root>

示例

¥Examples

延迟加载

¥Lazy Mounted

使用 unmountOnExit 属性使内容在折叠时卸载。

¥Use the unmountOnExit prop to make the content unmount when collapsed.

属性

¥Props

根元素

¥Root

PropDefaultType
lazyMount false
boolean

Whether to enable lazy mounting

unmountOnExit false
boolean

Whether to unmount on exit.

as
React.ElementType

The underlying element to render.

asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

For more details, read our Composition guide.
unstyled
boolean

Whether to remove the component's style.

defaultOpen
boolean

The initial open state of the collapsible when rendered. Use when you don't need to control the open state of the collapsible.

disabled
boolean

Whether the collapsible is disabled.

ids
Partial<{ root: string; content: string; trigger: string }>

The ids of the elements in the collapsible. Useful for composition.

onExitComplete
VoidFunction

The callback invoked when the exit animation completes.

onOpenChange
(details: OpenChangeDetails) => void

The callback invoked when the open state changes.

open
boolean

The controlled open state of the collapsible.

Previous

面包屑

Next

分页