Skip to main content

Typography

The typographic scale used by Catalyst components.

Create a Typography and pass it to ThemeData to customise the font family, sizes, weights, and individual styles. Typography supports three levels of customisation, in ascending specificity:

  1. fontFamily — applies to all non-overridden body styles (p1, p2, body, p3, caption, micro). Defaults to null, which lets Flutter fall through to the platform default.
  2. headerFontFamily — applies to heading styles (display, h1, h2, h3); falls back to fontFamily when null, so you only need to set it when headers should use a different typeface.
  3. Per-style TextStyle overrides — individual constructor parameters (display:, h1:, h2:, h3:, p1:, p2:, body:, p3:, caption:, micro:) that replace the computed default for that slot entirely. Overridden styles are used verbatim — fontFamily, headerFontFamily, and colorScheme are not merged into them.

Fields

FieldTypeDescription
fontFamilyString?Typeface for body-level styles. null uses the platform default.
headerFontFamilyString?Typeface for heading-level styles (display, h1, h2, h3). Falls back to fontFamily when null.
colorSchemeColorSchemeRequired. Binds the default text colour for non-overridden styles; set automatically when attached to a ThemeData.

Style getters

Each getter returns the explicit override if one was supplied to the constructor, otherwise a computed default built from _headerBase (heading styles) or _bodyBase (body styles):

GetterBaseSizeWeightLine heightDescription
displayheader40 spFontWeight.w7001Hero numbers and large display text.
h1header28 spFontWeight.w6001Page-level heading.
h2header22 spFontWeight.w6001Section heading.
h3header18 spFontWeight.w5001Sub-section heading.
p1body20 spFontWeight.w5001Large paragraph text.
p2body18 spFontWeight.w4001Secondary paragraph text.
bodybody16 spFontWeight.w4001Default body copy.
p3body14 spFontWeight.w4001Supporting body copy.
captionbody12 spFontWeight.w4001Captions and helper text.
microbody10 spFontWeight.w5001Micro labels and badges.

defaultStyle is an additional getter equal to body; it is used as the ambient DefaultTextStyle set up by the Theme widget.

_bodyBase and _headerBase are private getters — the two base TextStyle values that embed the appropriate font family and the colorScheme.text colour. headerFontFamily ?? fontFamily is used for _headerBase; fontFamily alone is used for _bodyBase.

Overriding

Single font family:

Typography(colorScheme: myScheme, fontFamily: 'Inter')

Different font families for headers and body:

Typography(
colorScheme: myScheme,
fontFamily: 'Inter',
headerFontFamily: 'Playfair Display',
)

Override individual styles:

Typography(
colorScheme: myScheme,
display: TextStyle(fontSize: 48, fontWeight: FontWeight.w800),
body: TextStyle(fontSize: 15, height: 1.6),
)

Override via an existing theme:

themeData.copyWith(
typography: themeData.typography.copyWith(
body: TextStyle(fontSize: 15, height: 1.6),
),
);

copyWith and withColorScheme both thread every field —fontFamily, headerFontFamily, and each per-style override — through to the new instance; withColorScheme additionally rebinds colorScheme while preserving every style override and font family setting.

ThemeData.light() and ThemeData.dark() build a default Typography internally from fontFamily when no explicit typography is supplied, then call withColorScheme to bind it to the resolved ColorScheme. See Context extensions for how components read the active Typography via context.typography.