Typography排版

文本的基本格式。

何时使用

  • 当需要展示标题、段落、列表内容时使用,如文章/博客/日志的文本样式。
  • 当需要一列基于文本的基础操作时,如拷贝/省略/可编辑。

代码演示

Typography排版 - 图1

基本

展示文档样例。

  1. import { Component } from '@angular/core';
  2. @Component({
  3. selector: 'nz-demo-typography-basic',
  4. template: `
  5. <article nz-typography>
  6. <h1 nz-typography>Introduction</h1>
  7. <p nz-typography>
  8. In the process of internal desktop applications development, many different design specs and implementations would be involved,
  9. which might cause designers and developers difficulties and duplication and reduce the efficiency of development.
  10. </p>
  11. <p nz-typography>
  12. After massive project practice and summaries, Ant Design, a design language for backgroundapplications, is refined by Ant UED Team,
  13. which aims to
  14. <span nz-typography
  15. ><strong
  16. >uniform the user interface specs for internal background projects, lower the unnecessary cost of design differences and
  17. implementation and liberate the resources ofdesign and front-end development</strong
  18. ></span
  19. >.
  20. </p>
  21. <h2 nz-typography>Guidelines and Resources</h2>
  22. <p nz-typography>
  23. We supply a series of design principles, practical patterns and high quality design resources (<span nz-typography
  24. ><code>Sketch</code></span
  25. >
  26. and <span nz-typography><code>Axure</code></span
  27. >), to help people create their product prototypes beautifully and efficiently.
  28. </p>
  29. <article nz-typography>
  30. <ul>
  31. <li>
  32. <a href="/docs/spec/proximity">Principles</a>
  33. </li>
  34. <li>
  35. <a href="/docs/pattern/navigation">Patterns</a>
  36. </li>
  37. <li>
  38. <a href="/docs/resource/download">Resource Download</a>
  39. </li>
  40. </ul>
  41. </article>
  42. <nz-divider></nz-divider>
  43. <h1 nz-typography>介绍</h1>
  44. <p nz-typography>
  45. 蚂蚁的企业级产品是一个庞大且复杂的体系。这类产品不仅量级巨大且功能复杂,而且变动和并发频繁,常常需要设计与开发能够快速的做出响应。
  46. 同时这类产品中有存在很多类似的页面以及组件,可以通过抽象得到一些稳定且高复用性的内容。
  47. </p>
  48. <p nz-typography>
  49. 随着商业化的趋势,越来越多的企业级产品对更好的用户体验有了进一步的要求。带着这样的一个终极目标,我们(蚂蚁金服体验技术部)
  50. 经过大量的项目实践和总结,逐步打磨出一个服务于企业级产品的设计体系 Ant Design。 基于<span nz-typography
  51. ><mark>『确定』和『自然』</mark></span
  52. >的设计价值观,通过模块化的解决方案,降低冗余的生产成本, 让设计者专注于<span nz-typography><strong>更好的用户体验</strong></span
  53. >。
  54. </p>
  55. <h2 nz-typography>
  56. 设计资源
  57. </h2>
  58. <p nz-typography>
  59. 我们提供完善的设计原则、最佳实践和设计资源文件 (<span nz-typography><code>Sketch</code></span> 和
  60. <span nz-typography><code>Axure</code></span
  61. >),来帮助业务快速设计出高质 量的产品原型。
  62. </p>
  63. <article nz-typography>
  64. <ul>
  65. <li>
  66. <a href="/docs/spec/proximity">设计原则</a>
  67. </li>
  68. <li>
  69. <a href="/docs/pattern/navigation">设计模式</a>
  70. </li>
  71. <li>
  72. <a href="/docs/resource/download">设计资源</a>
  73. </li>
  74. </ul>
  75. </article>
  76. </article>
  77. `
  78. })
  79. export class NzDemoTypographyBasicComponent {}

Typography排版 - 图2

标题组件

展示不同级别的标题。

  1. import { Component } from '@angular/core';
  2. @Component({
  3. selector: 'nz-demo-typography-title',
  4. template: `
  5. <h1 nz-typography>h1. Ant Design</h1>
  6. <h2 nz-typography>h2. Ant Design</h2>
  7. <h3 nz-typography>h3. Ant Design</h3>
  8. <h4 nz-typography>h4. Ant Design</h4>
  9. `,
  10. styles: []
  11. })
  12. export class NzDemoTypographyTitleComponent {}

Typography排版 - 图3

可交互

提供额外的交互能力。

  1. import { Component } from '@angular/core';
  2. @Component({
  3. selector: 'nz-demo-typography-interactive',
  4. template: `
  5. <p nz-typography nzEditable [(nzContent)]="editStr"></p>
  6. <p nz-typography nzCopyable nzEditable [(nzContent)]="copyStr"></p>
  7. <p nz-typography nzCopyable nzCopyText="Hello, Ant Design!">Replace copy text.</p>
  8. `
  9. })
  10. export class NzDemoTypographyInteractiveComponent {
  11. editStr = 'This is an editable text.';
  12. copyStr = 'This is a copyable text.';
  13. }

Typography排版 - 图4

文本组件

内置不同样式的文本。

  1. import { Component } from '@angular/core';
  2. @Component({
  3. selector: 'nz-demo-typography-text',
  4. template: `
  5. <span nz-typography>Ant Design</span>
  6. <br />
  7. <span nz-typography nzType="secondary">Ant Design</span>
  8. <br />
  9. <span nz-typography nzType="warning">Ant Design</span>
  10. <br />
  11. <span nz-typography nzType="danger">Ant Design</span>
  12. <br />
  13. <span nz-typography nzDisabled>Ant Design</span>
  14. <br />
  15. <span nz-typography><mark>Ant Design</mark></span>
  16. <br />
  17. <span nz-typography><code>Ant Design</code></span>
  18. <br />
  19. <span nz-typography><u>Ant Design</u></span>
  20. <br />
  21. <span nz-typography><del>Ant Design</del></span>
  22. <br />
  23. <span nz-typography><strong>Ant Design</strong></span>
  24. `,
  25. styles: []
  26. })
  27. export class NzDemoTypographyTextComponent {}

Typography排版 - 图5

省略号

多行文本省略。

  1. import { Component } from '@angular/core';
  2. @Component({
  3. selector: 'nz-demo-typography-ellipsis',
  4. template: `
  5. <p nz-typography nzEllipsis>
  6. Ant Design, a design language for background applications, is refined by Ant UED Team. Ant Design, a design language for background
  7. applications, is refined by Ant UED Team. Ant Design, a design language for background applications, is refined by Ant UED Team. Ant
  8. Design, a design language for background applications, is refined by Ant UED Team. Ant Design, a design language for background
  9. applications, is refined by Ant UED Team. Ant Design, a design language for background applications, is refined by Ant UED Team.
  10. </p>
  11. <br />
  12. <p nz-typography nzEllipsis nzExpandable [nzEllipsisRows]="3">
  13. Ant Design, a design language for background applications, is refined by Ant UED Team. Ant Design, a design language for background
  14. applications, is refined by Ant UED Team. Ant Design, a design language for background applications, is refined by Ant UED Team. Ant
  15. Design, a design language for background applications, is refined by Ant UED Team. Ant Design, a design language for background
  16. applications, is refined by Ant UED Team. Ant Design, a design language for background applications, is refined by Ant UED Team.
  17. </p>
  18. <br />
  19. <p nz-typography nzEllipsis nzEditable [nzEllipsisRows]="2" [nzContent]="dynamicContent" (nzContentChange)="onChange($event)"></p>
  20. `
  21. })
  22. export class NzDemoTypographyEllipsisComponent {
  23. dynamicContent = `Ant Design, a design language for background applications, is refined by Ant UED Team.
  24. Ant Design, a design language for background applications, is refined by Ant UED Team.
  25. Ant Design, a design language for background applications, is refined by Ant UED Team.`;
  26. onChange(event: string): void {
  27. this.dynamicContent = event;
  28. }
  29. }

Typography排版 - 图6

后缀

添加后缀的省略。

  1. import { Component } from '@angular/core';
  2. @Component({
  3. selector: 'nz-demo-typography-suffix',
  4. template: `
  5. <nz-slider [(ngModel)]="rows" [nzMax]="10" [nzMin]="1"></nz-slider>
  6. <p nz-typography nzEllipsis nzExpandable [attr.title]="content + suffix" [nzEllipsisRows]="rows" [nzSuffix]="suffix">
  7. {{ content }}
  8. </p>
  9. `
  10. })
  11. export class NzDemoTypographySuffixComponent {
  12. content =
  13. 'To be, or not to be, that is a question: Whether it is nobler in the mind to suffer. The slings and arrows of outrageous fortune';
  14. suffix = '--William Shakespeare';
  15. rows = 1;
  16. }

API

[nz-typography]directive

参数说明类型默认值全局配置
[nzContent]组件内容string-
[nzCopyable]是否可拷贝,需要配合 [nzContent] 使用booleanfalse
[nzEditable]是否可编辑,需要配合 [nzContent] 使用booleanfalse
[nzEllipsis]自动溢出省略,动态内容时需要配合 [nzContent] 使用booleanfalse
[nzExpandable]自动溢出省略时是否可展开booleanfalse
[nzSuffix]自动溢出省略时的文本后缀string-
[nzCopyText]自定义被拷贝的文本string-
[nzDisabled]禁用文本booleanfalse
[nzEllipsisRows]自动溢出省略时省略行数number1
[nzType]文本类型‘secondary’|’warning’|’danger’-
(nzContentChange)当用户提交编辑内容时触发EventEmitter<string>-
(nzExpandChange)展开省略文本时触发EventEmitter<void>-