Skip to Content
文档

边框

用于设置边框和边框半径样式的 JSX 样式属性。

边框半径

¥Border Radius

所有边

¥All sides

使用 roundedborderRadius 属性在元素的所有边上应用边框半径。

¥Use the rounded or borderRadius props to apply border radius on all sides of an element.

<Box borderRadius="md" />
<Box rounded="md" /> // shorthand
属性CSS 属性标记类别
rounded, borderRadiusborder-radiusradii

特定边

¥Specific sides

使用 rounded{Left,Right,Top,Bottom}border{Left,Right,Top,Bottom}Radius 属性在元素的特定侧应用边框半径。

¥Use the rounded{Left,Right,Top,Bottom} or border{Left,Right,Top,Bottom}Radius prop, to apply border radius on a specific side of an element.

<Box borderTopRadius="md" />
<Box roundedTop="md" /> // shorthand

<Box borderLeftRadius="md" />
<Box roundedLeft="md" /> // shorthand

使用逻辑等效组件使边框半径根据文本方向进行调整。

¥Use the logical equivalent to make the border radius adapt based on the text direction.

<Box roundedStart="md" />
<Box roundedEnd="md" />
属性CSS 属性标记类别
roundedLeft, borderLeftRadiusborder-left-radiusradii
roundedRight, borderRightRadiusborder-right-radiusradii
roundedTop, borderTopRadiusborder-top-radiusradii
roundedBottom, borderBottomRadiusborder-bottom-radiusradii
roundedStart, borderStartRadiusborder-start-start-radius, border-end-start-radiusradii
roundedEnd, borderEndRadiusborder-start-end-radius, border-end-end-radiusradii

特定角

¥Specific corners

使用 border{Top,Bottom}{Left,Right}Radius 属性或等效的简写形式将特定角设为圆角。

¥Use the border{Top,Bottom}{Left,Right}Radius properties, or the shorthand equivalent to round a specific corner.

<Box borderTopLeftRadius="md" />
<Box roundedTopLeft="md" /> // shorthand

使用逻辑属性根据文本方向进行调整。

¥Use the logical properties to adapt based on the text direction.

<Box borderStartStartRadius="md" />
<Box roundedStartStart="md" /> // shorthand
属性CSS 属性标记类别
roundedTopLeft,borderTopLeftRadiusborder-top-left-radiusradii
roundedTopRight,borderTopRightborder-top-right-radiusradii
roundedBottomRight,borderBottomRightborder-bottom-right-radiusradii
roundedBottomLeft,borderBottomLeftborder-bottom-left-radiusradii

边框宽度

¥Border Width

所有边

¥All sides

使用 borderWidth 属性在元素的所有侧应用边框宽度。

¥Use the borderWidth prop to apply border width on all sides of an element.

Chakra 默认应用 borderStyle: solid 和全局边框颜色。指定边框宽度即可应用边框。

<Box borderWidth="1px" />
属性CSS 属性标记类别
borderWidthborder-widthborderWidths

特定边

¥Specific sides

使用 border{Left|Right|Top|Bottom}Width 属性在元素的特定侧应用边框宽度。

¥Use the border{Left|Right|Top|Bottom}Width prop to apply border width on a specific side of an element.

<Box borderTopWidth="1px" />
<Box borderLeftWidth="1px" />

使用逻辑等效组件使边框宽度根据文本方向进行调整。

¥Use the logical equivalent to make the border width adapt based on the text direction.

<Box borderInlineStartWidth="1px" />
<Box borderInlineWidth="1px" /> // shorthand
属性CSS 属性标记类别
borderTopWidthborder-top-widthborderWidths
borderLeftWidthborder-left-widthborderWidths
borderRightWidthborder-right-widthborderWidths
borderBottomWidthborder-bottom-widthborderWidths
borderStartWidth , borderInlineStartWidthborder-{start+end}-width
borderEndWidth , borderInlineEndWidthborder-{start+end}-width
borderXWidth , borderInlineWidthborder-{left,right}-widthborderWidths
borderYWidth , borderBlockWidthborder-{top,bottom}-widthborderWidths

边框颜色

¥Border Color

所有边

¥All sides

使用 borderColor 属性在元素的所有侧应用边框颜色。

¥Use the borderColor prop to apply border color on all sides of an element.

<Box borderColor="red.400" />

// with opacity modifier
<Box borderColor="red.400/20" />

特定边

¥Specific sides

使用 border{Left,Right,Top,Bottom}Color 属性在元素的特定侧应用边框颜色。

¥Use the border{Left,Right,Top,Bottom}Color prop to apply border color on a specific side of an element.

<Box borderTopColor="red.400" />
<Box borderLeftColor="red.400" />

使用逻辑属性根据文本方向进行调整。

¥Use the logical properties to adapt based on the text direction.

<Box borderStartColor="red.400" />
<Box borderEndColor="red.400" />
属性CSS 属性标记类别
borderColorborder-colorcolors
borderTopColorborder-top-colorcolors
borderLeftColorborder-left-colorcolors
borderRightColorborder-right-colorcolors
borderBottomColorborder-bottom-colorcolors
borderStartColor , borderInlineStartColorborder-{start,end}-colorcolors
borderEndColor , borderInlineEndColorborder-{start,end}-colorcolors
borderXColor, borderInlineColorborder-inline-colorcolors
borderYColor, borderBlockColorborder-block-colorcolors

分隔符宽度

¥Divide Width

使用 divide{X,Y}Width 属性在元素之间应用边框宽度。它会使用 CSS 选择器 > * + * 来应用 border* 属性。

¥Use the divide{X,Y}Width prop to apply border width between elements. It uses the CSS selector > * + * to apply the border* properties.

<Box divideXWidth="1px">
  <Box>1</Box>
  <Box>2</Box>
</Box>

<Box divideYWidth="1px">
  <Box>1</Box>
  <Box>2</Box>
</Box>
属性CSS 属性标记类别
divideWidthborder-{inline,block}-start-widthborderWidths

分隔符颜色

¥Divide Color

使用 divideColor 属性在元素之间应用边框颜色。

¥Use the divideColor prop to apply border color between elements.

<Box divideColor="red.400">
  <Box>1</Box>
  <Box>2</Box>
</Box>
属性CSS 属性标记类别
divideColor--divide-colorcolors

分隔符样式

¥Divide Style

使用 divideStyle 属性在元素之间应用边框样式。

¥Use the divideStyle prop to apply border style between elements.

<Box divideX="2px" divideStyle="dashed">
  <Box>1</Box>
  <Box>2</Box>
</Box>
属性CSS 属性标记类别
divideStyle--divide-styleborderStyle

Previous

背景

Next

显示