Skip to Content
文档

图标按钮

用于在按钮内渲染图标

SourceStorybookRecipe

用法

¥Usage

import { IconButton } from "@chakra-ui/react"
<IconButton aria-label="Search database">
  <LuSearch />
</IconButton>

示例

¥Examples

尺寸

¥Sizes

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

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

xs

sm

md

lg

变量

¥Variants

使用 variant 属性更改其视觉样式

¥Use the variant prop to change its visual style

solid

subtle

surface

outline

ghost

颜色

¥Color

使用 colorPalette 属性更改按钮的颜色

¥Use the colorPalette prop to change the color of the button

圆角

¥Rounded

设置 rounded="full",使按钮完全圆润。

¥Set rounded="full" to make the button fully rounded

属性

¥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

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

下载触发器