Skip to content

Typography

Typography component for consistent text styling with predefined variants.

import { Typography } from '@truongdq01/ui';
<Typography variant="h1">Heading 1</Typography>;
PropTypeDefaultDescription
childrenReactNodeText content
variantTypographyVariant"body1"Text style variant
align"left" | "right" | "center" | "justify" | "inherit""left"Text alignment
color"primary" | "secondary" | "tertiary" | "disabled" | "brand" | "error" | string"primary"Text color
gutterBottombooleanfalseAdd margin bottom
noWrapbooleanfalseTruncate to single line
paragraphbooleanfalseAdd paragraph margin
display"none" | "flex" | "contents" | "block" | "inline" | "inline-flex"CSS display property
styleTextStyleAdditional inline styles
<Typography variant="h1">Heading 1 - 2.5rem / 32px</Typography>
<Typography variant="h2">Heading 2 - 2rem / 28px</Typography>
<Typography variant="h3">Heading 3 - 1.75rem / 24px</Typography>
<Typography variant="h4">Heading 4 - 1.5rem / 20px</Typography>
<Typography variant="h5">Heading 5 - 1.25rem / 18px</Typography>
<Typography variant="h6">Heading 6 - 1rem / 16px</Typography>
<Typography variant="subtitle1">Subtitle 1 - 1rem / 16px, Medium weight</Typography>
<Typography variant="subtitle2">Subtitle 2 - 0.875rem / 14px, Medium weight</Typography>
<Typography variant="body1">Body 1 - 1rem / 16px, Regular weight (default)</Typography>
<Typography variant="body2">Body 2 - 0.875rem / 14px, Regular weight</Typography>
<Typography variant="caption">Caption - 0.75rem / 12px, Regular weight</Typography>
<Typography variant="button">Button - 0.875rem / 14px, Medium weight</Typography>
<Typography variant="overline">Overline - 0.75rem / 12px, Uppercase</Typography>
<Typography variant="inherit">Inherit - Inherits parent styles</Typography>
<Typography align="left">Left aligned text</Typography>
<Typography align="center">Center aligned text</Typography>
<Typography align="right">Right aligned text</Typography>
<Typography align="justify">Justified text</Typography>
<Typography color="primary">Primary text color</Typography>
<Typography color="secondary">Secondary text color</Typography>
<Typography color="tertiary">Tertiary text color</Typography>
<Typography color="disabled">Disabled text color</Typography>
<Typography color="brand">Brand color</Typography>
<Typography color="error">Error color</Typography>
<Typography color="#FF5733">Custom hex color</Typography>
// Single line with ellipsis
<Typography noWrap>
This is a very long text that will be truncated with an ellipsis if it exceeds
the container width
</Typography>
// Add margin bottom
<Typography gutterBottom>Text with bottom margin</Typography>
// Paragraph spacing
<Typography paragraph>First paragraph</Typography>
<Typography paragraph>Second paragraph</Typography>
<Typography display="block">Block level text</Typography>
<Typography display="inline">Inline text</Typography>
<Typography display="inline-flex">Inline flex container</Typography>
<Typography variant="h1" align="center" gutterBottom>
Welcome to RNUI
</Typography>
<Typography variant="subtitle1" align="center" color="secondary">
A beautiful UI component library
</Typography>
<Card>
<Typography variant="h6" gutterBottom>
Card Title
</Typography>
<Typography variant="body2" color="secondary">
Card description text goes here.
</Typography>
</Card>
<Typography variant="subtitle2" gutterBottom>
Email Address
</Typography>
<Input placeholder="name@example.com" />
<Typography variant="caption" color="error">
Please enter a valid email address
</Typography>
<Input label="Password" />
<Typography variant="caption" color="tertiary">
Must be at least 8 characters
</Typography>
  • Use semantic heading hierarchy (h1 → h2 → h3)
  • Keep body text at readable size (16px minimum)
  • Use appropriate line height for readability
  • Maintain color contrast for accessibility
  • Don’t skip heading levels (h1 → h3)
  • Don’t use tiny text (< 12px)
  • Don’t use low contrast colors for body text
  • Don’t use too many font variants on one page
<Typography
variant="h2"
accessibilityRole="header"
accessibilityLevel={2}
>
Section Title
</Typography>
<Typography
variant="body1"
accessibilityRole="text"
>
Descriptive text content
</Typography>
VariantFont SizeLine HeightWeightUse Case
h12.5rem (40px)1.2700Page titles
h22rem (32px)1.2600Section headers
h31.75rem (28px)1.3600Subsections
h41.5rem (24px)1.3600Card titles
h51.25rem (20px)1.4600Group headers
h61rem (16px)1.4600Item headers
subtitle11rem (16px)1.5500Secondary headings
subtitle20.875rem (14px)1.5500Small subtitles
body11rem (16px)1.6400Body text (default)
body20.875rem (14px)1.6400Secondary body
caption0.75rem (12px)1.5400Captions, hints
button0.875rem (14px)1.5500Button text
overline0.75rem (12px)1.5500Labels, overlines
  • Text - React Native Text component
  • Icon - Icons to pair with text
  • Link - Clickable text links