Fonts
Define font families with createFont and load custom fonts on native.
Fonts are the one token category with structure. Each family carries its own size, line height, weight, and letter spacing scales.
Create one with createFont and pass it to createTamagui under fonts:
tamagui.config.ts
Keys can be any string. The tamagui components expect number keys 1 through 10
on size, so headings and sized text resolve automatically.
createFont fills gaps for you. When lineHeight, weight, or letterSpacing
define fewer keys than size, each missing key carries the previous value forward,
and keys before the first one you define take that first value:
Set settings.defaultFont to the key of the family that text should use when no
fontFamily is given. See Settings.
Face
On Android, React Native picks a font file by name and ignores fontWeight. The
face map tells Tamagui which file name to use for each weight and style. Without
it, every weight renders with the same file. iOS and web ignore face.
Loading fonts on native
React Native has to load custom font files before it can use them. Tamagui does not
handle loading. With Expo, use useFonts from expo-font and gate rendering on the
result. The Expo guide walks through both
@tamagui/font-inter and @expo-google-fonts. Without Expo, follow the React Native
docs for linking font assets.
The name you load must match the name used in family and in face:
App.tsx
Using font tokens
Text components read a family with fontFamily. Style props such as fontSize
and lineHeight accept a key from that family’s scale. SizableText, Paragraph,
and the headings take a size prop that picks fontSize, lineHeight, weight,
and letterSpacing from the family together:
Per-language fonts
A font name with a _ suffix is a language variant of the base family. Define
body_cn next to body and load both font files:
FontLanguage then switches a family for a whole subtree. Every component
reading fontFamily="body" inside it picks up the variant, with no prop
changes on the text itself:
The suffix name is yours to choose. The reserved value default resets a
family to its base font:
On web, FontLanguage swaps a CSS variable, so changing language does not
re-render the text.