通过 truncated 属性,在文本超过视图或最大宽度设置时展示省略符。通过 line-clamp 属性控制多行的样式 Starting from version 2.14.6, isTruncated is exposed to indicate whether the text is truncated. You can use it to show a tooltip only when truncation occurs.
Self element set width 100px
Squeezed by parent element
The -webkit-line-clamp CSS property allows limiting of the contents of a block to the specified number of lines.
Show tooltip only when the text is truncated
export function TextTruncated() {
return (
<>
<ElText className={`${styles.w150} ${styles.mb2}`} truncated>
Self element set width 100px
</ElText>
<ElRow className={`${styles.row} ${styles.w150}`}>
<ElText truncated>Squeezed by parent element</ElText>
</ElRow>
<ElRow className={styles.row}>
<ElText lineClamp={2}>
The -webkit-line-clamp CSS property
<br />
allows limiting of the contents of
<br />a block to the specified number of lines.
</ElText>
</ElRow>
<ElRow>
<ElText className={styles.w150} truncated>
Show tooltip only when the text is truncated
</ElText>
</ElRow>
</>
);
}
覆盖
使用属性 tag 覆盖元素
span
This is a paragraph.
Bold
Italic
This is subscript
This is superscript
Inserted
Deleted
Marked
export function TextOverride() {
return (
<ElSpace direction="vertical">
<ElText>span</ElText>
<ElText tag="p">This is a paragraph.</ElText>
<ElText tag="b">Bold</ElText>
<ElText tag="i">Italic</ElText>
<ElText>
This is{" "}
<ElText tag="sub" size="small" className={styles.sub}>subscript</ElText>
</ElText>
<ElText>
This is{" "}
<ElText tag="sup" size="small" className={styles.sup}>superscript</ElText>
</ElText>
<ElText tag="ins">Inserted</ElText>
<ElText tag="del">Deleted</ElText>
<ElText tag="mark">Marked</ElText>
</ElSpace>
);
}