Back to Ant Design

Typography

components/typography/index.en-US.md

6.3.78.2 KB
Original Source

When To Use

  • When you need to display a title or paragraph contents in Articles/Blogs/Notes.
  • When you need copyable/editable/ellipsis texts.

Examples

<!-- prettier-ignore -->

<code src="./demo/basic.tsx">Basic</code> <code src="./demo/title.tsx">Title Component</code> <code src="./demo/paragraph-debug.tsx" debug>Title and Paragraph</code> <code src="./demo/text.tsx">Text and Link Component</code> <code src="./demo/editable.tsx">Editable</code> <code src="./demo/copyable.tsx">Copyable</code> <code src="./demo/ellipsis.tsx">Ellipsis</code> <code src="./demo/ellipsis-controlled.tsx" version="5.16.0">Controlled ellipsis expand/collapse</code> <code src="./demo/ellipsis-middle.tsx">Ellipsis from middle</code> <code src="./demo/ellipsis-debug.tsx" debug>Ellipsis Debug</code> <code src="./demo/suffix.tsx">suffix</code> <code src="./demo/componentToken-debug.tsx" debug>Component Token</code> <code src="./demo/link-danger-debug.tsx" debug>Link danger Debug</code>

API

Common props ref:Common props

Typography.Text

PropertyDescriptionTypeDefaultVersion
codeCode stylebooleanfalse
copyableWhether to be copyable, customize it via setting an objectboolean | copyablefalse
deleteDeleted line stylebooleanfalse
disabledDisabled contentbooleanfalse
editableIf editable. Can control edit state when is objectboolean | editablefalse
ellipsisDisplay ellipsis when text overflows, can't configure expandable, rows and onExpand by using object. Diff with Typography.Paragraph, Text do not have 100% width style which means it will fix width on the first ellipsis. If you want to have responsive ellipsis, please set width manuallyboolean | Omit<ellipsis, 'expandable' | 'rows' | 'onExpand'>false
keyboardKeyboard stylebooleanfalse4.3.0
markMarked stylebooleanfalse
onClickSet the handler to handle click event(event) => void-
strongBold stylebooleanfalse
italicItalic stylebooleanfalse4.16.0
typeContent typesecondary | success | warning | danger-success: 4.6.0
underlineUnderlined stylebooleanfalse

Typography.Title

PropertyDescriptionTypeDefaultVersion
codeCode stylebooleanfalse
copyableWhether to be copyable, customize it via setting an objectboolean | copyablefalse
deleteDeleted line stylebooleanfalse
disabledDisabled contentbooleanfalse
editableIf editable. Can control edit state when is objectboolean | editablefalse
ellipsisDisplay ellipsis when text overflows, can configure rows and expandable by using objectboolean | ellipsisfalse
levelSet content importance. Match with h1, h2, h3, h4, h5number: 1, 2, 3, 4, 515: 4.6.0
markMarked stylebooleanfalse
onClickSet the handler to handle click event(event) => void-
italicItalic stylebooleanfalse4.16.0
typeContent typesecondary | success | warning | danger-success: 4.6.0
underlineUnderlined stylebooleanfalse

Typography.Paragraph

PropertyDescriptionTypeDefaultVersion
codeCode stylebooleanfalse
copyableWhether to be copyable, customize it via setting an objectboolean | copyablefalse
deleteDeleted line stylebooleanfalse
disabledDisabled contentbooleanfalse
editableIf editable. Can control edit state when is objectboolean | editablefalse
ellipsisDisplay ellipsis when text overflows, can configure rows and expandable by using objectboolean | ellipsisfalse
markMarked stylebooleanfalse
onClickSet the handler to handle click event(event) => void-
strongBold stylebooleanfalse
italicItalic stylebooleanfalse4.16.0
typeContent typesecondary | success | warning | danger-success: 4.6.0
underlineUnderlined stylebooleanfalse

copyable

{
  text: string | (() => string | Promise<string>),
  onCopy: function(event),
  icon: ReactNode,
  tooltips: false | [ReactNode, ReactNode],
  format: 'text/plain' | 'text/html',
  tabIndex: number,
}
PropertyDescriptionTypeDefaultVersion
formatThe Mime Type of the text'text/plain' | 'text/html'-4.21.0
iconCustom copy icon: [copyIcon, copiedIcon][ReactNode, ReactNode]-4.6.0
textThe text to copystring-
tooltipsCustom tooltip text, hide when it is false[ReactNode, ReactNode][Copy, Copied]4.4.0
onCopyCalled when copied textfunction-
tabIndexSet tabIndex of the copy buttonnumber05.17.0

editable

{
  icon: ReactNode,
  tooltip: ReactNode,
  editing: boolean,
  maxLength: number,
  autoSize: boolean | { minRows: number, maxRows: number },
  text: string,
  onChange: function(string),
  onCancel: function,
  onStart: function,
  onEnd: function,
  triggerType: ('icon' | 'text')[],
  enterIcon: ReactNode,
  tabIndex: number,
}
PropertyDescriptionTypeDefaultVersion
autoSizeautoSize attribute of textareaboolean | { minRows: number, maxRows: number }-4.4.0
editingWhether to be editablebooleanfalse
iconCustom editable iconReactNode<EditOutlined />4.6.0
maxLengthmaxLength attribute of textareanumber-4.4.0
tooltipCustom tooltip text, hide when it is falseReactNodeEdit4.6.0
textEdit text, specify the editing content instead of using the children implicitlystring-4.24.0
onChangeCalled when input at textareafunction(value: string)-
onCancelCalled when type ESC to exit editable statefunction-
onStartCalled when enter editable statefunction-
onEndCalled when type ENTER to exit editable statefunction-4.14.0
triggerTypeEdit mode trigger - icon, text or both (not specifying icon as trigger hides it)Array<icon|text>[icon]
enterIconCustom "enter" icon in the edit field (passing null removes the icon)ReactNode<EnterOutlined />4.17.0
tabIndexSet tabIndex of the edit buttonnumber05.17.0

ellipsis

tsx
interface EllipsisConfig {
  rows: number;
  /** `collapsible` added in `5.16.0` */
  expandable: boolean | 'collapsible';
  suffix: string;
  /** render function added in `5.16.0` */
  symbol: ReactNode | ((expanded: boolean) => ReactNode);
  tooltip: ReactNode | TooltipProps;
  /** added in `5.16.0` */
  defaultExpanded: boolean;
  /** added in `5.16.0` */
  expanded: boolean;
  /** `info` added in `5.16.0` */
  onExpand: (event: MouseEvent, info: { expanded: boolean }) => void;
  onEllipsis: (ellipsis: boolean) => void;
}
PropertyDescriptionTypeDefaultVersion
expandableWhether to be expandableboolean | 'collapsible'-collapsible: 5.16.0
rowsMax rows of contentnumber-
suffixSuffix of ellipsis contentstring-
symbolCustom description of ellipsisReactNode | ((expanded: boolean) => ReactNode)Expand Collapse
tooltipShow tooltip when ellipsisReactNode | TooltipProps-4.11.0
defaultExpandedDefault expand or collapseboolean5.16.0
expandedExpand or Collapseboolean5.16.0
onEllipsisCalled when enter or leave ellipsis statefunction(ellipsis)-4.2.0
onExpandCalled when expand contentfunction(event, { expanded: boolean })-info: 5.16.0

Design Token

<ComponentTokenTable component="Typography"></ComponentTokenTable>