Skip to Content
文档

文本

用于在界面内渲染文本和段落。

Source

Sphinx of black quartz, judge my vow.

用法

¥Usage

import { Text } from "@chakra-ui/react"
<Text>This is the text component</Text>

示例

¥Examples

尺寸

¥Sizes

使用 fontSizetextStyle prop 更改文本的大小。

¥Use the fontSize or textStyle prop to change the size of the text.

Chakra

Chakra

Chakra

Chakra

Chakra

Chakra

Chakra

Chakra

Chakra

Chakra

Chakra

权重

¥Weights

使用 fontWeight 属性更改文本的粗细。

¥Use the fontWeight prop to change the weight of the text.

Sphinx of black quartz, judge my vow.

Sphinx of black quartz, judge my vow.

Sphinx of black quartz, judge my vow.

Sphinx of black quartz, judge my vow.

Sphinx of black quartz, judge my vow.

截断

¥Truncation

使用 truncate 属性在单行后截断文本。

¥Use the truncate prop to truncate the text after a single line.

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

线条限制

¥Line Clamp

使用 lineClamp 属性在一定行数后截断文本。

¥Use the lineClamp prop to truncate the text after a certain number of lines.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

参考

¥Ref

以下是如何访问底层元素引用的示例

¥Here's how to access the underlying element reference

const Demo = () => {
  const ref = useRef<HTMLParagraphElement | null>(null)
  return <Text ref={ref}>This is the text component</Text>
}

Previous

散文

Next

按钮