Usage
The @carbon/type package enables you to use typography from the IBM Design Language, including the type scale and fonts, along with typography design tokens from the Carbon Design System. It also comes with opinionated defaults for type styles on common elements like h1, h2, p, etc.
You can use this package by writing the following:
In particular, you can use the following classes:
Class | Description |
|---|---|
| Set the |
| Set the |
| Set the |
| Style the HTML element with the given type token |
Type styles
Instead of using a type scale, @carbon/type provides tokens that represent what we call type styles. These tokens have a variety of properties for styling how text is rendered on a page.
You can find a full reference of the type styles that are available on the Carbon Design System website .
You can include a type token in your Sass file by using the type-style mixin from the Carbon type package.
This reset sets some top-level properties on html and body, namely font-size, font-family, and some text-rendering options. We also map the strong tag to the semibold font weight.
Type scale
A type scale is provided through the $type-scale variable and corresponding type-scale function and mixin. However, for specifying type styles, the recommendation is to use type styles .
If you are looking to use the type scale, you can include all the scale-related utilities and variables by writing the following in your Sass file:
You can access a specific step in the type scale by using the type-scale function: