尺寸
了解如何在 Chakra UI 中自定义尺寸
示例
¥Example
以下是如何在 Chakra UI 中自定义大小的示例。
¥Here's an example of how to customize sizes in Chakra UI.
theme.ts
import { createSystem, defaultConfig, defineConfig } from "@chakra-ui/react"
const customConfig = defineConfig({
theme: {
tokens: {
sizes: {
"1/7": { value: "14.285%" },
"2/7": { value: "28.571%" },
"3/7": { value: "42.857%" },
},
},
},
})
export const system = createSystem(defaultConfig, customConfig)
用法
¥Usage
将所有与尺寸相关的属性(例如 width
、height
、minWidth
、minHeight
、maxWidth
、maxHeight
等)的值设置为 sizes
令牌。
¥Set the value of any size related properties, like width
, height
,
minWidth
, minHeight
, maxWidth
, maxHeight
, etc. to the sizes
token.
<Box width="1/7" height="2/7" />