Typography

A custom text component with predefined variant styles for consistent typography across your application.

Import

import { Typography } from '@tidbcloud/uikit'

Basic Usage

import { Typography } from '@tidbcloud/uikit'
 
function Demo() {
  return <Typography variant="headline-lg">Large Headline Text</Typography>
}

Variants

Typography supports 18 predefined variants organized into 5 categories:

Headlines

import { Typography, Stack } from '@tidbcloud/uikit'
 
function Demo() {
  return (
    <Stack>
      <Typography variant="headline-lg">Headline Large (24px, 700)</Typography>
      <Typography variant="headline-md">Headline Medium (20px, 700)</Typography>
      <Typography variant="headline-sm">Headline Small (18px, 700)</Typography>
    </Stack>
  )
}

Titles

import { Typography, Stack } from '@tidbcloud/uikit'
 
function Demo() {
  return (
    <Stack>
      <Typography variant="title-lg">Title Large (16px, 700)</Typography>
      <Typography variant="title-md">Title Medium (14px, 700)</Typography>
      <Typography variant="title-sm">Title Small (12px, 700)</Typography>
    </Stack>
  )
}

Actions

import { Typography, Stack } from '@tidbcloud/uikit'
 
function Demo() {
  return (
    <Stack>
      <Typography variant="action-lg">Action Large (16px, 600)</Typography>
      <Typography variant="action-md">Action Medium (14px, 600)</Typography>
      <Typography variant="action-sm">Action Small (12px, 600)</Typography>
    </Stack>
  )
}

Labels

import { Typography, Stack } from '@tidbcloud/uikit'
 
function Demo() {
  return (
    <Stack>
      <Typography variant="label-lg">Label Large (14px, 500)</Typography>
      <Typography variant="label-md">Label Medium (13px, 500)</Typography>
      <Typography variant="label-sm">Label Small (12px, 500)</Typography>
      <Typography variant="label-xs">Label Extra Small (11px, 500)</Typography>
    </Stack>
  )
}

Body

import { Typography, Stack } from '@tidbcloud/uikit'
 
function Demo() {
  return (
    <Stack>
      <Typography variant="body-lg">Body Large (14px, 400)</Typography>
      <Typography variant="body-md">Body Medium (13px, 400)</Typography>
      <Typography variant="body-sm">Body Small (12px, 400)</Typography>
      <Typography variant="body-xs">Body Extra Small (11px, 400)</Typography>
    </Stack>
  )
}

Polymorphic Component

Typography can render as any HTML element using the component prop:

import { Typography } from '@tidbcloud/uikit'
 
function Demo() {
  return (
    <>
      <Typography variant="headline-lg" component="h1">
        As H1 Element
      </Typography>
      <Typography variant="body-md" component="span">
        As Span Element
      </Typography>
    </>
  )
}

Override Styles

You can override the default styles using standard Mantine Text props:

import { Typography } from '@tidbcloud/uikit'
 
function Demo() {
  return (
    <Typography variant="body-md" c="blue" fw={700}>
      Custom colored and bold text
    </Typography>
  )
}

Props

PropTypeDefaultDescription
variantTypographyVariants-Predefined typography style
componentElementType'div'HTML element to render
cMantineColor-Text color (overrides variant)
fzMantineSize-Font size (overrides variant)
fwnumber-Font weight (overrides variant)
lhstring | number-Line height (overrides variant)

Variant Reference

VariantFont SizeLine HeightFont WeightColor
headline-lg24px32px700carbon.9
headline-md20px30px700carbon.9
headline-sm18px28px700carbon.9
title-lg16px24px700carbon.9
title-md14px20px700carbon.9
title-sm12px18px700carbon.9
action-lg16px24px600peacock.7
action-md14px20px600peacock.7
action-sm12px18px600peacock.7
label-lg14px20px500carbon.8
label-md13px18px500carbon.8
label-sm12px18px500carbon.8
label-xs11px16px500carbon.8
body-lg14px20px400carbon.8
body-md13px18px400carbon.8
body-sm12px18px400carbon.8
body-xs11px16px400carbon.8