2019-02-19 11:42:05 +08:00
---
category: Components
type: General
title: Typography
cols: 1
2020-05-31 11:48:34 +08:00
cover: https://gw.alipayobjects.com/zos/alicdn/GOM1KQ24O/Typography.svg
2019-02-19 11:42:05 +08:00
---
2019-03-19 11:40:36 +08:00
Basic text writing, including headings, body text, lists, and more.
2019-02-19 11:42:05 +08:00
## When To Use
2019-10-25 09:56:30 +08:00
- When need to display a title or paragraph contents in Articles/Blogs/Notes.
2019-03-19 11:40:36 +08:00
- When you need copyable/editable/ellipsis texts.
2019-02-19 11:42:05 +08:00
## API
### Typography.Text
2019-07-11 14:14:33 +08:00
| Property | Description | Type | Default | Version |
| --- | --- | --- | --- | --- |
2019-11-22 10:33:34 +08:00
| code | Code style | boolean | false | |
2020-08-10 10:44:16 +08:00
| copyable | Whether to be copyable, customize it via setting an object | boolean \| [copyable ](#copyable ) | false | [copyable ](#copyable ) |
2019-11-22 10:33:34 +08:00
| delete | Deleted line style | boolean | false | |
| disabled | Disabled content | boolean | false | |
2020-08-10 10:44:16 +08:00
| editable | If editable. Can control edit state when is object | boolean \| [editable ](#editable ) | false | [editable ](#editable ) |
2021-09-24 16:56:38 +08:00
| ellipsis | Display ellipsis when text overflows, can't configure expandable、rows and onExpand by using object | boolean \| [Omit<ellipsis, 'expandable' \| 'rows' \| 'onExpand'> ](#ellipsis ) | false | [ellipsis ](#ellipsis ) |
2020-05-16 14:43:29 +08:00
| keyboard | Keyboard style | boolean | false | 4.3.0 |
2020-10-21 10:33:43 +08:00
| mark | Marked style | boolean | false | |
2021-03-23 13:32:37 +08:00
| onClick | Set the handler to handle click event | (event) => void | - | |
2019-11-22 10:33:34 +08:00
| strong | Bold style | boolean | false | |
2021-05-24 16:24:00 +08:00
| italic | Italic style | boolean | false | 4.16.0 |
2020-08-13 10:13:32 +08:00
| type | Content type | `secondary` \| `success` \| `warning` \| `danger` | - | success: 4.6.0 |
2020-10-21 10:33:43 +08:00
| underline | Underlined style | boolean | false | |
2019-02-19 11:42:05 +08:00
### Typography.Title
2019-07-11 14:14:33 +08:00
| Property | Description | Type | Default | Version |
| --- | --- | --- | --- | --- |
2019-11-22 10:33:34 +08:00
| code | Code style | boolean | false | |
2020-08-10 10:44:16 +08:00
| copyable | Whether to be copyable, customize it via setting an object | boolean \| [copyable ](#copyable ) | false | [copyable ](#copyable ) |
2019-11-22 10:33:34 +08:00
| delete | Deleted line style | boolean | false | |
| disabled | Disabled content | boolean | false | |
2020-08-10 10:44:16 +08:00
| editable | If editable. Can control edit state when is object | boolean \| [editable ](#editable ) | false | [editable ](#editable ) |
| ellipsis | Display ellipsis when text overflows, can configure rows and expandable by using object | boolean \| [ellipsis ](#ellipsis ) | false | [ellipsis ](#ellipsis ) |
2020-07-28 20:39:43 +08:00
| level | Set content importance. Match with `h1` , `h2` , `h3` , `h4` , `h5` | number: 1, 2, 3, 4, 5 | 1 | 5: 4.6.0 |
2019-11-22 10:33:34 +08:00
| mark | Marked style | boolean | false | |
2021-03-23 13:32:37 +08:00
| onClick | Set the handler to handle click event | (event) => void | - | |
2021-05-24 16:24:00 +08:00
| italic | Italic style | boolean | false | 4.16.0 |
2020-10-21 10:33:43 +08:00
| type | Content type | `secondary` \| `success` \| `warning` \| `danger` | - | success: 4.6.0 |
2019-11-22 10:33:34 +08:00
| underline | Underlined style | boolean | false | |
2019-02-19 11:42:05 +08:00
### Typography.Paragraph
2019-07-11 14:14:33 +08:00
| Property | Description | Type | Default | Version |
| --- | --- | --- | --- | --- |
2019-11-22 10:33:34 +08:00
| code | Code style | boolean | false | |
2020-08-10 10:44:16 +08:00
| copyable | Whether to be copyable, customize it via setting an object | boolean \| [copyable ](#copyable ) | false | [copyable ](#copyable ) |
2019-11-22 10:33:34 +08:00
| delete | Deleted line style | boolean | false | |
| disabled | Disabled content | boolean | false | |
2020-08-10 10:44:16 +08:00
| editable | If editable. Can control edit state when is object | boolean \| [editable ](#editable ) | false | [editable ](#editable ) |
| ellipsis | Display ellipsis when text overflows, can configure rows and expandable by using object | boolean \| [ellipsis ](#ellipsis ) | false | [ellipsis ](#ellipsis ) |
2019-11-22 10:33:34 +08:00
| mark | Marked style | boolean | false | |
2021-03-23 13:32:37 +08:00
| onClick | Set the handler to handle click event | (event) => void | - | |
2019-11-22 10:33:34 +08:00
| strong | Bold style | boolean | false | |
2021-05-24 16:24:00 +08:00
| italic | Italic style | boolean | false | 4.16.0 |
2020-08-13 10:13:32 +08:00
| type | Content type | `secondary` \| `success` \| `warning` \| `danger` | - | success: 4.6.0 |
2020-10-21 10:33:43 +08:00
| underline | Underlined style | boolean | false | |
2020-05-11 14:28:57 +08:00
2020-08-09 12:56:35 +08:00
### copyable
2020-10-21 10:33:43 +08:00
{
text: string,
2022-03-22 16:52:44 +08:00
onCopy: function(event),
2020-10-21 10:33:43 +08:00
icon: ReactNode,
tooltips: false | [ReactNode, ReactNode],
2022-04-25 09:49:48 +08:00
format: 'text/plain' | 'text/html',
2020-10-21 10:33:43 +08:00
}
2020-08-09 12:56:35 +08:00
2020-08-10 10:44:16 +08:00
| Property | Description | Type | Default | Version |
| --- | --- | --- | --- | --- |
2022-06-06 14:35:53 +08:00
| format | The Mime Type of the text | 'text/plain' \| 'text/html' | - | 4.21.0 |
2020-10-21 10:33:43 +08:00
| icon | Custom copy icon: \[copyIcon, copiedIcon] | \[ReactNode, ReactNode] | - | 4.6.0 |
2020-08-10 10:44:16 +08:00
| text | The text to copy | string | - | |
2020-10-21 10:33:43 +08:00
| tooltips | Custom tooltip text, hide when it is false | \[ReactNode, ReactNode] | \[`Copy` , `Copied` ] | 4.4.0 |
2020-08-10 10:44:16 +08:00
| onCopy | Called when copied text | function | - | |
2020-08-09 12:56:35 +08:00
### editable
2020-10-21 10:33:43 +08:00
{
icon: ReactNode,
tooltip: boolean | ReactNode,
editing: boolean,
maxLength: number,
autoSize: boolean | { minRows: number, maxRows: number },
onStart: function,
onChange: function(string),
2021-03-13 23:46:32 +08:00
onCancel: function,
onEnd: function,
2021-09-23 22:14:43 +08:00
triggerType: ('icon' | 'text')[],
2021-09-22 21:54:27 +08:00
enterIcon: ReactNode,
2020-10-21 10:33:43 +08:00
}
2020-08-10 10:44:16 +08:00
| Property | Description | Type | Default | Version |
| --- | --- | --- | --- | --- |
2020-10-21 10:33:43 +08:00
| autoSize | `autoSize` attribute of textarea | boolean \| { minRows: number, maxRows: number } | - | 4.4.0 |
2020-08-10 10:44:16 +08:00
| editing | Whether to be editable | boolean | false | |
2020-10-21 10:33:43 +08:00
| icon | Custom editable icon | ReactNode | < EditOutlined /> | 4.6.0 |
2020-08-10 10:44:16 +08:00
| maxLength | `maxLength` attribute of textarea | number | - | 4.4.0 |
2020-10-21 10:33:43 +08:00
| tooltip | Custom tooltip text, hide when it is false | boolean \| ReactNode | `Edit` | 4.6.0 |
2021-09-23 22:14:43 +08:00
| onStart | Called when enter editable state | function | - | |
2022-07-08 22:10:24 +08:00
| onChange | Called when input at textarea | function(value: string) | - | |
2021-09-23 22:14:43 +08:00
| onCancel | Called when type ESC to exit editable state | function | - | |
2021-03-14 16:35:09 +08:00
| onEnd | Called when type ENTER to exit editable state | function | - | 4.14.0 |
2021-09-23 22:14:43 +08:00
| triggerType | Edit mode trigger - icon, text or both (not specifying icon as trigger hides it) | Array< `icon`\|`text` > | \[`icon` ] | |
2021-09-22 21:54:27 +08:00
| enterIcon | Custom "enter" icon in the edit field (passing `null` removes the icon) | ReactNode | `<EnterOutlined />` | 4.17.0 |
2021-07-22 15:03:29 +08:00
2020-08-10 10:44:16 +08:00
### ellipsis
2020-08-09 12:56:35 +08:00
2020-10-21 10:33:43 +08:00
{
rows: number,
expandable: boolean,
suffix: string,
symbol: ReactNode,
2021-01-27 17:26:38 +08:00
tooltip: boolean | ReactNode,
2020-10-21 10:33:43 +08:00
onExpand: function(event),
onEllipsis: function(ellipsis),
}
2020-08-09 12:56:35 +08:00
2021-01-12 16:46:59 +08:00
| Property | Description | Type | Default | Version |
| --- | --- | --- | --- | --- |
| expandable | Whether to be expandable | boolean | - | |
| rows | Max rows of content | number | - | |
2021-01-27 17:26:38 +08:00
| suffix | Suffix of ellipsis content | string | - | |
| symbol | Custom description of ellipsis | ReactNode | `Expand` | |
2021-01-12 16:46:59 +08:00
| tooltip | Show tooltip when ellipsis | boolean \| ReactNode | - | 4.11.0 |
| onEllipsis | Called when enter or leave ellipsis state | function(ellipsis) | - | 4.2.0 |
| onExpand | Called when expand content | function(event) | - | |
2020-08-09 12:56:35 +08:00
2020-05-11 14:28:57 +08:00
## FAQ
### How to use Typography.Link in react-router?
`react-router` support [customize ](https://github.com/ReactTraining/react-router/blob/master/packages/react-router-dom/docs/api/Link.md#component-reactcomponent ) render component:
```tsx
< Link to = "/" component = {Typography.Link} / >
```
2022-01-19 19:05:25 +08:00
**Note: ** This is not equivalent to the execution logic of react-router's Link [reference ](https://github.com/ant-design/ant-design/pull/26737/files#r488769888 )