Skip to Content
文档

代码

用于显示内联代码。

SourceStorybookRecipe
console.log("Hello, world!")

用法

¥Usage

import { Code } from "@chakra-ui/react"
<Code>Hello world</Code>

示例

¥Examples

尺寸

¥Sizes

使用 size 属性更改代码组件的大小。

¥Use the size prop to change the size of the code component.

console.log()console.log()console.log()console.log()

变量

¥Variants

使用 variant 属性更改代码组件的外观。

¥Use the variant prop to change the appearance of the code component.

console.log()console.log()console.log()console.log()

颜色

¥Colors

使用 colorPalette 属性更改组件的配色方案。

¥Use the colorPalette prop to change the color scheme of the component.

gray

console.log()console.log()console.log()console.log()

red

console.log()console.log()console.log()console.log()

green

console.log()console.log()console.log()console.log()

blue

console.log()console.log()console.log()console.log()

teal

console.log()console.log()console.log()console.log()

pink

console.log()console.log()console.log()console.log()

purple

console.log()console.log()console.log()console.log()

cyan

console.log()console.log()console.log()console.log()

orange

console.log()console.log()console.log()console.log()

yellow

console.log()console.log()console.log()console.log()

属性

¥Props

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

The color palette of the component

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

The variant of the component

size 'sm'
'xs' | 'sm' | 'md' | 'lg'

The size of the component

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

代码块