Typography 排版

排版组件,支持 type 类型、主题色(含 mark 标记)、字重、对齐、复制和省略展开收起

演示

9:41

代码示例

<!-- 排版类型 type -->
  <re-typography class="demo-type-title" type="title" weight="bold" size="large">标题 Title</re-typography>
  <re-typography class="demo-type-text" type="text">普通文本 Text,用于行内说明文字。</re-typography>
  <re-typography class="demo-type-paragraph" type="paragraph">段落 Paragraph,用于大段说明性文字,段落之间有较大间距。这段文字用来展示段落排版的效果。</re-typography>

<!-- 主题色 -->
  <re-typography class="demo-default">默认文本</re-typography>
  <re-typography class="demo-primary" theme="primary">主要文本</re-typography>
  <re-typography class="demo-danger" theme="danger">危险文本</re-typography>
  <re-typography class="demo-warning" theme="warning">警告文本</re-typography>
  <re-typography class="demo-success" theme="success">成功文本</re-typography>
  <re-typography class="demo-mark" theme="mark">标记背景色黄色高亮</re-typography>

<!-- 尺寸 -->
  <re-typography class="demo-small" size="small">小号文本</re-typography>
  <re-typography class="demo-medium" size="medium">中号文本</re-typography>
  <re-typography class="demo-large" size="large">大号文本</re-typography>

<!-- 字重 -->
  <re-typography class="demo-regular" weight="regular">常规字重</re-typography>
  <re-typography class="demo-weight-medium" weight="medium">中等字重</re-typography>
  <re-typography class="demo-bold" weight="bold">加粗字重</re-typography>

<!-- 对齐方式 -->
  <re-typography class="demo-align-left" align="left">左对齐文本</re-typography>
  <re-typography class="demo-align-center" align="center">居中对齐文本</re-typography>
  <re-typography class="demo-align-right" align="right">右对齐文本</re-typography>

<!-- 可复制 -->
  <re-typography class="demo-copyable" :copyable="true" content="可复制的文本内容">可复制的文本内容</re-typography>
  <re-typography class="demo-copyable-primary" :copyable="true" content="可复制的主要文本" theme="primary">可复制的主要文本</re-typography>

<!-- 文本省略 -->
  <re-typography class="demo-ellipsis" :ellipsis="true" :lines="1">这是一段很长的文本内容,超过一行时会显示省略号,用来测试文本省略功能是否正常工作</re-typography>
  <re-typography class="demo-ellipsis-2" :ellipsis="true" :lines="2">这是两行省略的文本内容,超过两行时会显示省略号,用来测试多行文本省略功能是否正常工作,这段文字需要足够长才能看到效果</re-typography>

<!-- 折叠省略(展开/收起) -->
  <re-typography class="demo-collapsible" :ellipsis="true" :lines="2" :collapsible="true"> TDesign 是腾讯开源的企业级设计体系,致力于为设计师和开发者提供统一的设计语言和组件库。TDesign 秉持开放的设计理念,与开源社区共同打造多维度的设计体系,覆盖 Web、小程序、移动端和桌面端等多个平台。通过 TDesign,团队可以快速构建高质量的产品界面,提升用户体验和开发效率。点击展开可以查看完整内容,点击收起可以恢复省略状态。这段文字足够长,确保超过两行后显示省略号和展开按钮。 </re-typography>

<!-- 自定义样式 -->
  <re-typography class="demo-custom-style" customStyle="margin-top: 10px;">自定义样式文本</re-typography>

<!-- 组合使用 -->
  <re-typography class="demo-combo" theme="primary" size="large" weight="bold" align="center">主要大号加粗居中</re-typography>
  <re-typography class="demo-combo-2" theme="danger" size="small" weight="medium">危险小号中等</re-typography>

引入

推荐使用 easycom 模式,配置后无需手动 import 即可直接使用 <re-typography />。

API

Typography Props

名称类型默认值描述必传
typestring'text'-N
themestring'default'主题风格N
sizestring'medium'尺寸N
weightstring'regular'-N
alignstring'left'-N
copyablebooleanfalse-N
contentstring''内容文字N
ellipsisbooleanfalse-N
linesnumber2-N
collapsiblebooleanfalse-N
customStylestring''自定义样式N

Typography Events

名称参数描述
click-点击时触发
copytext: string复制时触发

Typography Slots

名称描述
default默认插槽