Skip to content

Typography

A set of global utility classes for text: standard roles (headings, body, captions), weight, alignment, transformation and truncation. All classes use the .s-text-* prefix, are built on design tokens (--s-font-size-*, --s-font-weight-*, --s-line-height-*) and are available wherever @smalt-ui/core/styles.css is loaded, without wrapping anything in a component.

Families

The library ships the Inter font. Headings have their own token but use the same font as body text by default:

TokenFontUsed for
--s-font-sansIntereverything except headings
--s-font-headingvar(--s-font-sans).s-text-h1…h6 and component titles (dialogs, cards, steps)
--s-font-monoJetBrains Mono + systemmonospaced values

Font files are loaded through a separate entry, @smalt-ui/core/fonts.css; how to replace them or serve them yourself is described in Theming.

Scale

The roles follow the Material typography set (h1…h6, subtitle, body, caption, overline), but the values are adapted to Smalt UI tokens. Each class sets font-size, font-weight, line-height and letter-spacing at once.

Heading
Heading 1Inter.s-text-h1
Heading
Heading 2Inter.s-text-h2
Heading
Heading 3Inter.s-text-h3
Heading
Heading 4Inter.s-text-h4
Heading
Heading 5Inter.s-text-h5
Heading
Heading 6Inter.s-text-h6
Subtitle
Subtitle 1Inter.s-text-subtitle1
Subtitle
Subtitle 2Inter.s-text-subtitle2
Paragraph body text
Body 1Inter.s-text-body1
Paragraph body text
Body 2Inter.s-text-body2
Element caption
CaptionInter.s-text-caption
Overline text
OverlineInter.s-text-overline
Heading 1
Heading 3
Heading 5
Subtitle 1
Body 1: paragraph body text.
Caption: element caption
Overline
ClassSizeWeight
.s-text-h13.75rem300
.s-text-h23rem300
.s-text-h32.25rem400
.s-text-h41.875rem400
.s-text-h51.5rem400
.s-text-h61.25rem500
.s-text-subtitle11rem400
.s-text-subtitle20.875rem500
.s-text-body11rem400
.s-text-body20.875rem400
.s-text-caption0.75rem400
.s-text-overline0.75rem500 (uppercase)

Weight

The .s-text-weight-* classes change only font-weight and combine with any role.

Thin (100)Light (300)Normal (400)Medium (500)Semibold (600)Bold (700)Black (900)
Classfont-weight
.s-text-weight-thin100
.s-text-weight-light300
.s-text-weight-normal400
.s-text-weight-medium500
.s-text-weight-semibold600
.s-text-weight-bold700
.s-text-weight-black900

Alignment

Left
Center
Right
Justified: the line stretches to both edges of the block, with hyphenation (hyphens).
ClassEffect
.s-text-lefttext-align: left
.s-text-centertext-align: center
.s-text-righttext-align: right
.s-text-justifytext-align: justify + hyphens: auto

Transformation and decoration

uppercaseLOWERCASEevery word capitalizeditalicstrikethrough
ClassEffect
.s-text-uppercasetext-transform: uppercase
.s-text-lowercasetext-transform: lowercase
.s-text-capitalizetext-transform: capitalize
.s-text-italicfont-style: italic
.s-text-no-wrapwhite-space: nowrap
.s-text-striketext-decoration: line-through

Truncation

.s-text-truncate cuts a single line with an ellipsis; .s-text-truncate-2 / -3 cut at 2 and 3 lines respectively.

A single line that will not fit into a narrow container and gets cut with an ellipsis.
Two lines: long text wraps, and whatever does not fit into the two allotted lines is hidden behind an ellipsis at the end.
ClassEffect
.s-text-truncatesingle-line ellipsis truncation
.s-text-truncate-2truncation to 2 lines (line-clamp)
.s-text-truncate-3truncation to 3 lines (line-clamp)

Customization

Scale values are build-time SASS maps with !default, which can be overridden before @use:

  • $typography: roles (h1…overline), as (size, weight, leading, tracking) objects;
  • $font-size: font sizes (xs…6xl), $font-weight: weights (thin…black);
  • $font-sans / $font-heading / $font-mono: families.

Sizes and weights refer to the --s-font-size-* / --s-font-weight-* CSS variables, so individual scale values can also be changed at runtime by overriding the relevant variable.