Skip to the content

Text Size

The textSize prop sets the reading size of the whole theme — every font size and every sized icon — independently of the spacing density. Density answers the screen's needs; text size answers the reader's. A dense dashboard can still offer large text.
Theming

Levels

Value
Ratio
Body text (small)
Use for
smaller
×0.875
14px
data-dense views where every row counts
default
×1
16px
most products
larger
×1.125
18px
a larger reading size, by preference
largest
×1.25
20px
comfort, distance, shared screens
Scrolls sideways inside the table. The page does not.

The ratio applies to the whole scale (nano … gargantua), except that no size drops below 10px. Line height is unitless and letter spacing is in em, so both follow. The level multiplies the browser's root size and never replaces it: browser zoom and default font size still work on top of it.

compact + smaller
Dense layout, readable text.
compact + default
Dense layout, readable text.
compact + larger
Dense layout, readable text.
compact + largest
Dense layout, readable text.

Usage

Set it once at the application root and wire it to the reader's stored preference:

import { ApollionProvider } from '@apollion-dsi/core/themes';

<ApollionProvider dimension="compact" textSize={preferences.textSize}>
  <App />
</ApollionProvider>;

createTheme({ dimension: 'compact', textSize: 'larger' }) resolves the same values: spacing follows dimension (theme.spacing('medium') is 0.8rem), type follows textSize (theme.font.fontSize.small is 1.125rem). The resolved level is theme.font.textSize.

What it affects

  • Text — theme.font.fontSize.* (rem) and theme.font.fontSizePx.* (px, for layout math).
  • Icons — <Icon size> resolves through theme.font.sizing(...), which has the spacing keys but follows textSize. An icon without size inherits the surrounding font size.
  • Avatars — sized with theme.font.sizing, so the circle grows with its initials.

Spacing, borders, radius and colors do not change; they follow dimension and the brand.

Static tokens

The token build emits every level in css/font.css. default sits on :root; the data-apollion-text-size attribute switches the level on <html> or on any element. ApollionProvider writes that attribute on <html> (with syncDocument), so the CSS variables match the React theme. Without React, set it yourself:

<html data-apollion-text-size="larger">
  <head>
    <link rel="stylesheet" href="dist/css/default.light.positive.compact.css" />
    <link rel="stylesheet" href="dist/css/font.css" />
  </head>
</html>

With server rendering and a stored preference, render the attribute on the server so the first paint is right.

Pitfalls

  • Nesting a provider to enlarge one region → a nested provider rebuilds the whole theme, including brand, mode and preset. Scope a region with the data-apollion-text-size attribute on the CSS surface instead.
  • Expecting dimension to scale type → it scales spacing only. For the old look, pair compact with textSize="smaller" and spacious with textSize="largest" (close, not identical).

See also