Basic · Typography
Typography
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

Title

Use heading to set different levels of headint title.

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.
You could pass object to link, which will be mounted on <a>.

Paragraph

Paragraph component has two spacings. You could setspacing='extended' for a looser spacing.

Numeral

Based on Text component, added properties: rule, precision, truncate, parser, to provide the ability to handle Numeral in text separately.
Note
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
Parsing rules can be customised via parser.

Size

Paragraph and Text component support two sizes, small(12px) and normal(14px). By default it is set to normal
When the paragraph component or text component are used nested, set the size property of the inner component to inherit, and the size of the inner component will inherit the size setting of the outer component.

Copyable text

Copying of text can be supported by configuring the copyable property.
When copyable is configured as true, the default copied content is children itself. Note that at this time, children only support string type.
When copyable is configured as object, you can specify the content copied to the clipboard through copyable.content, which is no longer strongly associated with children.
At this time, children will no longer limit the type, but copyable.content still needs to be a string.
You can use the copyable.render attribute to customize the copyable button render.

Ellipsis

Show ellipsis if text is overflowed. Refer to Ellipsis Config for detailed configuration.
Notice
1. ellipsis only supports truncation of plain text, and does not support complex types such as reactNode. Please ensure that the content type of children is string

2. To achieve abbreviation, ellipsis needs to have a clear width or maxWidth limit for comparison and judgment. If the width is not set by itself (for example, purely relying on the flex property to expand), or the width is an indefinite value such as 100%, the parent needs to have a clear width or maxWidth

3. Ellipsis needs to obtain information such as the width and height of the DOM to make basic judgments. If there is a display:none style in itself or the parent, the value will be incorrect, and the abbreviation will be invalid at this time

4. For more information on ellipsis see FAQ
Tips
When the tooltip does not wrap in the pop-up tooltip when the long text occurs, please set it manually through word-break or word-wrap, more details can be found in the FAQ section of Tooltip

API Reference

Typography.Text

PropertiesInstructionstypeDefaultversion
copyableToggle whether to be copyableboolean | object:Copyable Configfalse
codewrap with code elementboolean-
componentCustom rendering html elementhtml elementspan
deleteDeleted stylebooleanfalse
disabledDisabled stylebooleanfalse
ellipsisDisplay ellipsis when text overflowsboolean|object:Ellipsis Configfalse
iconPrefix icon.ReactNode-
linkToggle whether to display as a link. When passing object, the attributes will be transparently passed to the a tagboolean|objectfalse
markMarked stylebooleanfalse
sizeSize, one of normal, small, inheritstringnormal
strongBold stylebooleanfalse
typeType, one of primary, secondary, warning, danger, tertiary(v>=1.2.0) , quaternary(v>=1.2.0), success(v>=1.7.0)stringprimary
underlineUnderlined stylebooleanfalse
weightset font weightnumber2.34.0

Typography.Title

PropertiesInstructionstypeDefaultversion
copyableToggle whether to be copyableboolean | object:Copyable Configfalse
componentCustom rendering html element. The default is determined by heading prophtml elementh1~h6
deleteDeleted stylebooleanfalse
disabledDisabled stylebooleanfalse
ellipsisDisplay ellipsis when text overflowsboolean|object:Ellipsis Configfalse
headingHeading level, one of 1, 2, 3,4,5,6number1
linkToggle whether to display as a link. When passing object, the attributes will be transparently passed to the a tagboolean|objectfalse
markMarked stylebooleanfalse
typeType, one of primary, secondary, warning, danger, tertiary(v>=1.2.0), quaternary(v>=1.2.0), success(v>=1.7.0)stringprimary
underlineUnderlined stylebooleanfalse
weightset font weight, one of light, regular, medium, semibold, bold, defaultstring, number2.34.0

Typography.Paragraph

PropertiesInstructionstypeDefaultversion
copyableToggle whether to be copyableboolean | object:Copyable Configfalse
componentCustom rendering html elementhtml elementp
deleteDeleted stylebooleanfalse
disabledDisabled stylebooleanfalse
ellipsisDisplay ellipsis when text overflowsboolean|object:Ellipsis Configfalse
linkToggle whether to display as a link. When passing object, the attributes will be transparently passed to the a tagboolean|objectfalse
markMarked stylebooleanfalse
sizeSize, one of normalsmallstringnormal
spacingparagraph spacing, one of normal, extendedstringnormal
strongBold stylebooleanfalse
typeType, one of primary, secondary, warning, danger, tertiary(v>=1.2.0), quaternary(v>=1.2.0), success(v>=1.7.0)stringprimary
underlineUnderlined stylebooleanfalse

Typography.Numeral

PropertiesInstructionstypeDefaultversion
ruleParsing rules, one of text, numbers, bytes-decimal, bytes-binary, percentages, currency, exponentialstringtext2.22.0
precisionallows you to set the number of decimal places to be retained, used to set precisionnumber02.22.0
truncateThe truncation of the number of decimal places, optionally ceil, floor, round, aligned with Math.ceil, Math.floor, Math.roundstringround2.22.0
parserCustom numeral parsing functions(str: string) => string-2.22.0
copyableToggle whether to be copyableboolean | object:Copyable Configfalse2.22.0
codewrap with code elementboolean-2.22.0
componentCustom rendering html elementhtml elementspan2.22.0
deleteDeleted stylebooleanfalse2.22.0
disabledDisabled stylebooleanfalse2.22.0
ellipsisDisplay ellipsis when text overflowsboolean | object:Ellipsis Configfalse2.22.0
iconPrefix icon.ReactNode-2.22.0
linkToggle whether to display as a link. When passing object, the attributes will be transparently passed to the a tagboolean | objectfalse2.22.0
markMarked stylebooleanfalse2.22.0
sizeSize, one of normalsmallstringnormal2.22.0
strongBold stylebooleanfalse2.22.0
typeType, one of primary, secondary, warning, danger, tertiary(v>=1.2.0) , quaternary(v>=1.2.0), success(v>=1.7.0)stringprimary2.22.0
underlineUnderlined stylebooleanfalse2.22.0

Ellipsis Config

PropertiesInstructionstypeDefault
collapseTextDisplayed text to collapsestringCollapse
collapsibleToggle whether text is collapsiblebooleanfalse
expandTextDisplayed text to expandstringExpand
expandableToggle whether text is expandablebooleanfalse
posPosition to start ellipsis, one of end, middlestringend
rowsNumber of rows that should not be truncatednumber1
showTooltipToggle whether to show tooltip, if passed in as object: type,type of component to show tooltip, one of Tooltip, Popover; opts, properties that will be passed directly to the component; renderTooltip, custom rendering popup layer componentboolean|{type: 'tooltip'|'popover', opts: object, renderTooltip: ((content: ReactNode, children: ReactNode)) => ReactNode}false
suffixText suffix that will not be truncatedstring-
onExpandCallback when expand or collapsefunction(expanded: bool, Event: e)-

Copyable Config

PropertiesInstructionsTypeDefaultVersion
contentCopied contentstring-
copyTipTooltip content when hovering over iconReact.node-
iconCustom render duplicate nodeReact.node-2.31.0
onCopyCallback for copy actionFunction(e:Event, content:string, res:boolean)-
renderCustom render copy node
function(copied, doCopy, configs)
-2.65.0
successTipSuccessful tip contentReact.node-

Content Guidelines

  • Link
    • Text links need to be clear and predictable, users should be able to predict what will happen when they click on the link
    • Do not mislead users by mislabeling links
    • Avoid using "Click here" or "Here" as stand-alone links
✅ Recommended usage❌ Deprecated usage
No spaces yet? Create space No spaces yet? Click here
  • Avoid using entire sentences as clickable text links, and instead use text that describes where to go as the link content
✅ Recommended usage❌ Deprecated usage
Views user documentation for detailsView user documentation for details
  • Using short terms or words as link text is more conducive to internationalization, to avoid the problem of link text being split due to different grammar and word order in different languages
✅ Recommended usage❌ Deprecated usage
Manage notifications toManage notifications to
  • When ending with a text link, there is no need to follow punctuation, except for the question mark "?"
✅ Recommended usage❌ Deprecated usage
No spaces yet? Create space No spaces yet? Click here
Forgot password ?Forgot password
  • Link text does not contain the articles "the, a, an"
✅ Recommended usage❌ Deprecated usage
View user documentation for detailsView the user documentation for details

Design Tokens

FAQ

  • What are the specific mechanism and precautions of Typography ellipsis?
    Semi ellipsis has two strategies, CSS ellipsis and JS ellipsis. When setting middle truncation (pos='middle')、 expandable、 suffix is not empty string、copyable, the JS ellipsis strategy is enabled. Otherwise, enable the CSS ellipsis strategy.
    In general CSS truncation performance is better than JS truncation. when the children and container size remain unchanged, CSS truncation only involves 1~2 calculations, while js truncation is based on dichotomy and may require multiple calculations.
    Pay attention to performance consumption when using a large number of Typography with ellipsis. For example, in Table, you can reduce performance loss by setting a reasonable pageSize for paging.