Skip to Content
文档

关闭按钮

用于触发关闭功能

StorybookRecipe

用法

¥Usage

import { CloseButton } from "@chakra-ui/react"
<CloseButton />

示例

¥Examples

尺寸

¥Sizes

使用 size 属性更改关闭按钮的大小。

¥Use the size prop to change the size of the close button.

变量

¥Variants

使用 variant 属性更改关闭按钮的外观。

¥Use the variant prop to change the appearance of the close button.

自定义图标

¥Custom Icon

将自定义图标传递给 CloseButton 组件的 children

¥Pass the custom icon to the children of the CloseButton component.

属性

¥Props

PropDefaultType
spinnerPlacement 'start'
'start' | 'end' | undefined

The placement of the spinner

colorPalette 'gray'
'gray' | 'red' | 'orange' | 'yellow' | 'green' | 'teal' | 'blue' | 'cyan' | 'purple' | 'pink'

The color palette of the component

size 'md'
'2xs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl'

The size of the component

variant 'solid'
'solid' | 'subtle' | 'surface' | 'outline' | 'ghost' | 'plain'

The variant of the component

loading
boolean | undefined

If `true`, the button will show a loading spinner.

loadingText
React.ReactNode | undefined

The text to show while loading.

spinner
React.ReactNode | undefined

The spinner to show while loading.

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.

Previous

按钮

Next

图标按钮