#4232·tamagui

Font tokens (fontSize/lineHeight/fontWeight) inside a styled() variant are dropped unless the variant also sets fontFamily

Author: shafikgomezCreated Sep 25, 2026Updated Sep 25, 2026

Current Behavior

Inside a styled() variant branch, font tokens for fontSize, lineHeight and fontWeight (for example '$Body-sm') are silently dropped and the component renders its default font size. The same tokens resolve correctly at the root of the styled() config, or inside the variant branch if that branch also sets fontFamily.

Expected Behavior

A font token in a variant branch resolves against the component's font family — from defaultFont, the base component's own fontFamily, or the styled() config root — the same way it does at the config root, and the way it did in 1.144.4.

Tamagui Version

2.7.7 (latest stable). The same source works in 1.144.4.

Platform (Web, iOS, Android)

Web (react-native-web 0.21.2) and native (React Native 0.83.4). The main case — tokens in a variant branch with and without fontFamily — is confirmed on web and on the React Native renderer under jest-expo (16 vs 14). The other rows in the table were measured on web.

Reproduction

A body font with named size keys:

typescript
const body = createFont({
  family: 'System',
  size:       { 'Body-sm': 14, 'Body-md': 16, true: 16 },
  lineHeight: { 'Body-sm': 20, 'Body-md': 24, true: 24 },
  weight:     { 'Body-sm': '400', 'Body-md': '400', true: '400' },
})

createTamagui({ fonts: { body }, defaultFont: 'body', /* tokens, themes, media … */ })

Components that differ only in where the tokens sit:

typescript
// ✗ renders 16px / 24px — the tokens are dropped and Input's default size applies
const InVariant = styled(Input, {
  variants: {
    size: {
      sm: { fontSize: '$Body-sm', fontWeight: '$Body-sm', lineHeight: '$Body-sm' },
    },
  } as const,
})

// ✓ renders 14px / 20px
const InVariantWithFamily = styled(Input, {
  variants: {
    size: {
      sm: {
        fontFamily: '$body',
        fontSize: '$Body-sm', fontWeight: '$Body-sm', lineHeight: '$Body-sm',
      },
    },
  } as const,
})

// ✓ renders 14px / 20px — same tokens, no fontFamily, at the config root
const AtRoot = styled(Input, {
  fontSize: '$Body-sm', fontWeight: '$Body-sm', lineHeight: '$Body-sm',
})

// ✗ renders 16px / 24px — fontFamily at the root does not reach the variant branch
const FamilyAtRoot = styled(Input, {
  fontFamily: '$body',
  variants: {
    size: {
      sm: { fontSize: '$Body-sm', fontWeight: '$Body-sm', lineHeight: '$Body-sm' },
    },
  } as const,
})
typescript
<InVariant size="sm" />
<InVariantWithFamily size="sm" />
<AtRoot />
<FamilyAtRoot size="sm" />
Case Result
Token in a variant branch, no fontFamily ✗ 16px / 24px, class _fs-f-size-4
Same branch + fontFamily ✓ 14px / 20px, class _fs-f-size-Body…
Same tokens at the config root, no fontFamily ✓ 14px / 20px
fontFamily at the config root, tokens in the branch ✗ 16px / 24px
Same shape on styled(Text) and styled(Label) ✗ also affected
1.144.4, tokens in a variant branch ✓ 14px / 20px

Two details that narrow it:

  • The branch itself runs. Adding backgroundColor to the same branch applies normally; only the three font-scoped properties are lost.
  • The component already has a font family. defaultFont: 'body' is set, and @tamagui/input's defaultStyles includes fontFamily: '$body'. Declaring fontFamily at the styled() root does not help either — only a fontFamily inside the same variant branch does, so the branch appears to be resolved without the component's font context.

It is easy to miss: the dropped token falls back to the font's true key, so when the intended values happen to match the default (here Body-md = 16px = true), the rendering is pixel-identical and only the emitted class differs.

How this was measured: the snippet above is the minimal shape of the bug rather than a standalone app. The results come from our app's Storybook on web (Vite, browser test runner) with a custom body font using named size keys as above, and on native from the React Native renderer, compared against 1.144.4 with identical component source. Happy to push a reproduction on starter-free if that helps.

System Info

  • macOS 26.5, Apple M1
  • Node 26.4.0, bun 1.2.23
  • tamagui / @tamagui/core 2.7.7
  • react 19.2.0, react-native 0.83.4, react-native-web 0.21.2
  • Web bundler: Vite (Storybook 10); native: Metro / Expo SDK 55