Skip to main content
url
string
required
URL to the font file. Supports .ttf and .otf formats.
family
string
required
The font family name, as defined in the font file metadata.
size
number
required
Font size in points.
relativeToTextStyle
string
A semantic text style (e.g. "body", "headline") to scale the font size relative to for Dynamic Type support. When set, the font scales with the user’s accessibility text size preference.

Support

Usage

Basic custom font

With Dynamic Type scaling

Multiple weights

Notes

  • The font file must be accessible from the provided URL at runtime.
  • Supported formats are .ttf and .otf.
  • CustomFont returns a FontComponent that is passed to the .font() modifier, not used as a standalone view.
  • When relativeToTextStyle is set, the font size scales with the user’s Dynamic Type preference, providing accessibility support.

See Also

  • Text — text display