Skip to content

Typography 排版

文本的基本格式。

何时使用

  • 当需要展示标题、段落、列表内容时。
  • 当需要一列基于文本的基础操作时,如拷贝、省略、可编辑。

代码演示

标题组件

vue
<template>
  <div>
    <a-typography-title>介绍</a-typography-title>
    <a-typography-title :level="2">介绍</a-typography-title>
    <a-typography-title :level="3">介绍</a-typography-title>
    <a-typography-title :level="4">介绍</a-typography-title>
    <a-typography-title :level="5">介绍</a-typography-title>
  </div>
</template>

文本组件

vue
<template>
  <div>
    <a-typography-text>Ant Design Vue (默认)</a-typography-text>
    <br />
    <a-typography-text type="secondary">Ant Design Vue (次要)</a-typography-text>
    <br />
    <a-typography-text type="success">Ant Design Vue (成功)</a-typography-text>
    <br />
    <a-typography-text type="warning">Ant Design Vue (警告)</a-typography-text>
    <br />
    <a-typography-text type="danger">Ant Design Vue (危险)</a-typography-text>
    <br />
    <a-typography-text disabled>Ant Design Vue (禁用)</a-typography-text>
    <br />
    <a-typography-text mark>Ant Design Vue (标记)</a-typography-text>
    <br />
    <a-typography-text code>Ant Design Vue (代码)</a-typography-text>
    <br />
    <a-typography-text keyboard>Ant Design Vue (键盘)</a-typography-text>
    <br />
    <a-typography-text underline>Ant Design Vue (下划线)</a-typography-text>
    <br />
    <a-typography-text delete>Ant Design Vue (删除线)</a-typography-text>
    <br />
    <a-typography-text strong>Ant Design Vue (加粗)</a-typography-text>
    <br />
    <a-typography-text italic>Ant Design Vue (斜体)</a-typography-text>
  </div>
</template>

可交互

vue
<template>
  <div>
    <a-typography-paragraph editable>这是一段可编辑的文字。</a-typography-paragraph>
    <a-typography-paragraph copyable>这是一段可复制的文字。</a-typography-paragraph>
    <a-typography-paragraph
      copyable="{ text: '复制的内容!' }"
    >
      点击复制文字。
    </a-typography-paragraph>
  </div>
</template>

省略号

vue
<template>
  <div>
    <a-typography-paragraph
      ellipsis
    >
      Ant Design,一套企业级 UI 设计语言和 Vue 组件库,具有统一的 UI 设计语言和开发框架,提升界面设计和前端开发的工作效率。
    </a-typography-paragraph>
    <a-typography-paragraph
      :ellipsis="{ rows: 2, expandable: true, symbol: 'more' }"
    >
      Ant Design,一套企业级 UI 设计语言和 Vue 组件库,具有统一的 UI 设计语言和开发框架,提升界面设计和前端开发的工作效率。Ant Design,一套企业级 UI 设计语言和 Vue 组件库,具有统一的 UI 设计语言和开发框架,提升界面设计和前端开发的工作效率。
    </a-typography-paragraph>
  </div>
</template>

API

Typography.Text

参数说明类型默认值版本
code添加代码样式booleanfalse
copyable是否可拷贝,为对象时可进行各种自定义boolean | copyablefalse
delete添加删除线样式booleanfalse
disabled禁用文本booleanfalse
editable是否可编辑,为对象时可对编辑进行控制boolean | editablefalse
ellipsis自动溢出省略,为对象时可设置省略行数、是否可展开、添加后缀等boolean | ellipsisfalse
keyboard添加键盘样式booleanfalse
mark添加标记样式booleanfalse
strong是否加粗booleanfalse
italic是否斜体booleanfalse
type文本类型secondary | success | warning | danger-
underline添加下划线样式booleanfalse

Typography.Title

参数说明类型默认值版本
code添加代码样式booleanfalse
copyable是否可拷贝,为对象时可进行各种自定义boolean | copyablefalse
delete添加删除线样式booleanfalse
disabled禁用文本booleanfalse
editable是否可编辑,为对象时可对编辑进行控制boolean | editablefalse
ellipsis自动溢出省略,为对象时可设置省略行数、是否可展开、添加后缀等boolean | ellipsisfalse
level重要程度,相当于 h1h2h3h4h5number: 1, 2, 3, 4, 51
mark添加标记样式booleanfalse
type文本类型secondary | success | warning | danger-
underline添加下划线样式booleanfalse

Typography.Paragraph

参数说明类型默认值版本
code添加代码样式booleanfalse
copyable是否可拷贝,为对象时可进行各种自定义boolean | copyablefalse
delete添加删除线样式booleanfalse
disabled禁用文本booleanfalse
editable是否可编辑,为对象时可对编辑进行控制boolean | editablefalse
ellipsis自动溢出省略,为对象时可设置省略行数、是否可展开、添加后缀等boolean | ellipsisfalse
mark添加标记样式booleanfalse
strong是否加粗booleanfalse
type文本类型secondary | success | warning | danger-
underline添加下划线样式booleanfalse

copyable

ts
{
  text: string,
  onCopy: function,
  icon: VNode,
  tooltips: false | [VNode, VNode],
  format: 'text/plain' | 'text/html',
}
参数说明类型默认值版本
format剪贴板数据的 Mime Type'text/plain' | 'text/html''text/plain'
icon自定义拷贝图标:[默认图标, 拷贝后的图标][VNode, VNode]-
text拷贝到剪贴板里的文本string-
tooltips自定义提示文案,为 false 时隐藏文案[VNode, VNode][复制, 复制成功]
onCopy拷贝成功的回调函数function-

editable

ts
{
  icon: VNode,
  tooltip: boolean | VNode,
  editing: boolean,
  maxlength: number,
  autoSize: boolean | { minRows: number, maxRows: number },
  text: string,
  onChange: function(string),
  onCancel: function,
  onStart: function,
  onEnd: function,
  triggerType: ('icon' | 'text')[],
  enterIcon: VNode,
}
参数说明类型默认值版本
autoSize自动 resize 文本域boolean |-
editing控制是否是编辑中状态booleanfalse
icon自定义编辑图标VNode<EditOutlined />
maxlength编辑中文本域最大长度number-
tooltip自定义提示文本,为 false 时关闭boolean | VNode编辑
text显示文本string-
triggerType编辑模式触发器类型,图标、文本或者两者都设置(不设置图标则无编辑功能)Array<icon|text>[icon]
onCancel按 ESC 退出编辑状态时触发function-
onChange文本域编辑时触发function(event)-
onEnd按 ENTER 结束编辑状态时触发function-
onStart进入编辑中状态时触发function-

ellipsis

ts
{
  rows: number,
  expandable: boolean,
  suffix: string,
  symbol: VNode,
  tooltip: boolean | VNode,
  onExpand: function(event),
  onEllipsis: function(ellipsis),
}
参数说明类型默认值版本
expandable是否可展开boolean-
rows最多显示的行数number-
suffix自定义省略内容后缀string-
symbol自定义展开描述文案VNode展开
tooltip省略时,展示提示信息boolean | VNode-
onEllipsis触发省略时的回调function(ellipsis)-
onExpand点击展开时的回调function(event)-

Released under the MIT License.