• Typography排版
    • 何时使用
    • 代码演示
    • API
      • [nz-typography]directive

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

    Typography排版 - 图2

    标题组件

    展示不同级别的标题。

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

    Typography排版 - 图3

    可交互

    提供额外的交互能力。

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

    Typography排版 - 图5

    省略号

    多行文本省略。

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

    API

    [nz-typography]directive

    p[nz-paragraph], span[nz-text], h1[nz-title], h2[nz-title], h3[nz-title], h4[nz-title] 的使用方法与 [nz-typography] 相同

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