Skip to main content

Typography

Library
UDS Base
Repository
github.com/telus/universal-design-system
Package
npmjs.com/package/@telus-uds/components-base
Package version
1.6.1
The quick brown fox jumps over the lazy dog

Introduction

import { Typography } from '@telus-uds/components-base'

Typography can be used to achieve a variety of different typographic styles. Size, weight, colour and semantic markup are all controlled using the variants described below.

Guidance

Headings

  • Be mindful of SEO and accessibility
  • Organize headers in a nested order: h1, then h2, then h3
  • Try not to skip levels where possible: h1, then h3
  • Use one h1 per page
  • For Hero overlays, Headlines, or Promo blocks, use DisplayHeading
  • For subtext in the Hero overlays, or Headlines, use Text

Spacing

Typography components do not have built-in margins. See the Box component to learn how to apply spacing to typography components.

Subscript and superscript

Typography component can accept text containing subscript or superscript wrapped in corresponding tags (<sub> or <sup>) and will render those according to the main text variant used:

Consider this: $01 first month1

Stream live TV2 on any screen2

Stream live TV or On Demand shows and movies on any screen with TELUS Pik TV3. Get Pik TV from just $10 a month, and get your first month for $0 when you sign up3.
warning

Note that our current font can have issues with special characters often used in superscript, e.g. ™, 🅪, 🅫, ®, etc., so it's strongly recommended to use ordinary letters in superscript instead whenever possible.

Accessibility

Separate semantic meaning from visual styling

The semantic HTML tag and visual appearance of the Typography component can be controlled independently using the variant and heading props together. This allows developers, designers, and content editors to represent headings with a certain style while rendering a HTML tag of their choice. It's important to maintain a correct order of heading level and not skip levels; for example, have a <h2> HTML element that directly follows a <h1>, or a <h3> that directly follows a <h2>. This simple yet powerful feature allows users of assistive technology to navigate through content predictably since headings represent information hierarchy, while we also balance an appropriate visual hierarchy.

In the promotional content example below.

  • The first line of text appears as a H4, but renders with a <h1> tag.
  • The second line of text appears as a Display2, but renders with a <h2>.
  • The third line of text appears as Large text, but renders with a <div>.

Consider this: $0 first month

Stream live TV on any screen

Stream live TV or On Demand shows and movies on any screen with TELUS Pik TV. Get Pik TV from just $10 a month, and get your first month for $0 when you sign up.

Props

NameTypeDefaultDescription
tag'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'blockquote' | 'code' | 'del' | 'em' | 'ins' | 'li' | 'strong' | 'label'typeof heading === 'string' ? heading : undefinedOptional semantic HTML tag, to apply to the text on web. Does not change styling. `tag` and `heading` props set the same thing, so shouldn't be used together (`tag` overrides `heading`). In native apps, if a header tag is provided ("h1", "h2" etc) and accessibilityRole prop is not defined, the accessibilityRole will default to "heading".
accessibilityRoleheading === true ? 'header' : undefined
blockboolfalseIf true, forces the element to behave as a View block even if nested in other text
align'auto' | 'left' | 'right' | 'center' | 'justify'undefinedWorks the same as css text-align, note that RN doesn't support "start" or "end" (see https://reactnative.dev/docs/text-style-props#textalign) Justify is known to make text harder to read, especially for people with dyslexia (see https://developer.mozilla.org/en-US/docs/Web/CSS/text-align#accessibility_concerns)
tokenscustomSystem tokens prop, see tokens for more details
variantobjectOfSystem variant prop, see variants for more details
heading'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | trueRenders the text as a semantic heading. If a html heading tag is provided, uses that tag on Web. Does not affect styling: <Typography heading="h2"> will render a <h2> that looks like plain text. Use both `heading` and `variant` props to render semantic headings that look like headings. In native apps, if this is `true` or any html heading tag string and accessibilityRole prop is not defined, the accessibilityRole will default to "heading".
childrennodeSame children allowed as a React Native <Text> node