--- localeCode: en-US order: 18 category: Basic title: Typography subTitle: Typography icon: doc-typography brief: The basic format of text, images, paragraphs, and numeric. --- ## When to Use - To display the text content of articles, blogs, logs, etc. - To take basic operations such as copying and omitting text. ## Demos ### How to import ```jsx import import { Typography } from '@douyinfe/semi-ui'; ``` ### Title Use `heading` to set different levels of headint title. ```jsx live=true import React from 'react'; import { Typography } from '@douyinfe/semi-ui'; function Demo() { const { Title } = Typography; return (
h1. Semi Design h2. Semi Design h3. Semi Design h4. Semi Design h5. Semi Design h6. Semi Design
); } ``` ### Text Text component has different built-in styles. You could also pass `icon` to use the build-in styles for icon. Different from passing icon to children, using `icon` for link will have no underline in compliance with Semi Design principles. ```jsx live=true import React from 'react'; import { Typography } from '@douyinfe/semi-ui'; function Demo() { const { Text } = Typography; return (
Text

Secondary

{'Tertiary v>=1.2.0'}

{'Quaternary v>=1.2.0'}

Warning

{'Success v>=1.7.0'}

Danger

Disabled

Default Mark

Example Code

Underline

Deleted

Strong
); } ``` You could pass object to `link`, which will be mounted on ``. ```jsx live=true import React from 'react'; import { Typography } from '@douyinfe/semi-ui'; import { IconLink } from '@douyinfe/semi-icons'; function Demo() { const { Text } = Typography; return (
Link

Open Website

} underline>Link
); } ``` ### Paragraph Paragraph component has two spacings. You could set`spacing='extended'` for a looser spacing. ```jsx live=true import React from 'react'; import { Typography } from '@douyinfe/semi-ui'; function Demo() { const { Paragraph, Title } = Typography; return (
Default Spacing {`Life's but a walking shadow, a poor player, that struts and frets his hour upon the stage, and then is heard no more; it is a tale told by an idiot, full of sound and fury, signifying nothing.`}
Extended Spacing {`Life's but a walking shadow, a poor player, that struts and frets his hour upon the stage, and then is heard no more; it is a tale told by an idiot, full of sound and fury, signifying nothing.`}
); } ``` ### Numeral Based on Text component, added properties: `rule`, `precision`, `truncate`, `parser`, to provide the ability to handle Numeral in text separately. The Numeral component recursively traverses Children to detect all numeric text within it for conversion and display, taking care to control the rendering structure hierarchy.
For Numeral components with a rule of percentage, the data processing rules have changed. In v2.22.0-v2.29.0, for num whose absolute value is greater than or equal to 1, the result is num%; for num whose absolute value is less than or equal to 1, the result is (num*100)%. After the v2.30.0 version, it is unified to (num*100)%.
`precision` allows you to set the number of decimal places to be retained, used to set precision `truncate` The truncation of the number of decimal places, optionally `ceil`, `floor`, `round`, aligned with Math.ceil, Math.floor, Math.round `rule` for setting the parsing rules - set to `percentages` to automatically convert numbers to percentages - set to `bytes-decimal` to automatically convert numbers to bytes, 1 KB is defined as 1000 bytes, (B, KB, MB, GB, TB, PB, EB, ZB, YB) - Set to `bytes-binary` automatically converts the number to the unit of display corresponding to bytes, 1 KiB is defined as equal to 1024 bytes, (B, KiB, MiB, GiB, TiB, PiB, EiB, ZiB, YiB) - When set to `text`, Automatic rounding of numbers only, based on the `precision` and `truncate` attributes - When set to `numbers`, non-numeric characters will be filtered and only numbers will be displayed - When set to `exponential`, numbers are automatically converted to scientific notation ```jsx live=true import React from 'react'; import { Typography } from '@douyinfe/semi-ui'; function Demo() { const { Numeral } = Typography; return (

Liked:1.6111e1 K

Views: 2.4444e2 K

Favorable rating: 0.915

My odds of winning this game are 0.6 and my odds of losing are 0.4.

Used: 1000

Available: {1024*1000}

Used: 1024

Available: {2e12}

); } ``` Parsing rules can be customised via `parser`. ```jsx live=true import React from 'react'; import { Typography } from '@douyinfe/semi-ui'; function Demo() { const { Numeral } = Typography; function parserTCH(oldVal) { return oldVal.split(' ').map(item => Number(item) ? `${item.replace(/(\d)(?=(?:\d{3})+(?:\.|$))/g, '$1,')}+` : item ).join(' '); } function Infos() { const data = [ { type: 'Stars', min: '6700' }, { type: 'Fork', min: '500' }, { type: 'Downloads', min: '3000000' }, { type: 'Contributors', min: '90' } ]; return data.map(item =>

{item.type}: {item.min}

); } return (
Semi Design value our users, any kind of contribution is welcome {Infos}
Trusted by {1e5} users, Go to website >>
); } ``` ### Size Paragraph and Text component support two sizes, `small`(12px) and `normal`(14px). By default it is set to `normal`。 ```jsx live=true import React from 'react'; import { Typography } from '@douyinfe/semi-ui'; function Demo() { const { Paragraph, Text } = Typography; return (
Normal {`Life's but a walking shadow, a poor player, that struts and frets his hour upon the stage, and then is heard no more; it is a tale told by an idiot, full of sound and fury, signifying nothing.`}
Small {`Life's but a walking shadow, a poor player, that struts and frets his hour upon the stage, and then is heard no more; it is a tale told by an idiot, full of sound and fury, signifying nothing.`}
); } ``` ### Interactive Copyable text. ```jsx live=true import React from 'react'; import { Typography, TextArea } from '@douyinfe/semi-ui'; import { IconSetting } from '@douyinfe/semi-icons'; function Demo() { const { Paragraph, Text, Numeral } = Typography; return (
Click the right icon to copy text. Click to copy text. Toast.success({ content: 'Successfully copied.' }) }}>Click the right icon to copy. Timestamp: {new Date().getTime()/1000}s }}>Custom Copy Node

Paste here: