Get started

Tamagui design tokens: map portable roles to tokens and themes

Stable shared values belong in Tamagui tokens. Appearance-dependent semantic colors belong in themes. Keep responsive rules and component behavior in the layers that control them. Then verify that one named component receives the intended values in light and dark on every platform you claim to support.

Updated November 27, 2026

Choose the destination from the value's behavior

Don't classify a value by the word used in its upstream filename. Classify it by what controls it. A spacing value that stays fixed in light and dark is a static token candidate. A surface color chosen by the active appearance belongs in a theme. A breakpoint describes a condition, while a pressed state describes component behavior. Those decisions may all be portable, but they don't belong in the same Tamagui object.

DecisionDestinationConsumer contract
Stable foundationSpacing, size, radius, color, or layer value that doesn't change by appearanceMatching predefined token categoryCompatible style props resolve names from that category
Semantic appearance roleSurface, content, border, or accent value selected by modeThemeThe same role name resolves through the active theme
Project-specific valueReusable duration, opacity, or another project valueCustom token category when retrieval and typing are usefulProject code must retrieve or interpret it unless documented property resolution applies
TypographyFont family, size, weight, and line-height contractFonts configuration and loading setupText consumers use the configured font contract
Responsive decisionA value or layout selected by a conditionMedia configuration or layout codeThe condition and its response remain explicit
Interaction behaviorHover, press, loading, validation, or permission behaviorComponent contract or application codeThe component decides when a state applies
Route each portable decision to the layer that can enforce its behavior.

A custom category is storage, not automatic styling behavior

Custom categories can improve naming, retrieval, and typing. Creating one doesn't teach padding, color, or another style prop to resolve it like a predefined category.

Keep token names distinct from literal pixels

Tamagui resolves named values according to the style property's category. Its design-system documentation also distinguishes token lookup from literal pixels. A bare string such as 4 can select the token named 4 for the relevant property, while a number is a pixel value. The documented px() helper makes a pixel literal explicit when a token has the same name.

import { px } from 'tamagui'

// Resolve the space token named "4" for this property.
const tokenPadding = { padding: '4' }

// Force a literal four-pixel value.
const literalPadding = { padding: px(4) }
Tamagui documents px() for an explicit pixel value when a token name could otherwise be selected.

Don't rename a portable scale to resemble Tamagui's default scale unless its relationships are genuinely equivalent. Tamagui's default configuration coordinates size, space, radius, and font keys. A project can define another scale, but matching key names alone doesn't establish matching intent.

Start with a bounded portable source

The following values are project-authored teaching data. They aren't copied from Ambient Sage, attributed to an Identity Forge export, or presented as tested cross-platform values. This shape is useful because it separates stable foundations, a custom category, and mode-dependent semantic roles before Tamagui enters the process.

export const portableSource = {
  sourceId: 'project-authored-account-summary',
  sourceRevision: 'example-1',
  static: {
    space: { control: 12, section: 24 },
    size: { control: 44, icon: 20 },
    radius: { control: 10, panel: 18 },
    zIndex: { base: 0, overlay: 100 },
  },
  custom: {
    duration: { quick: 120, deliberate: 240 },
  },
  themes: {
    light: {
      surface: '#f7f7f4',
      content: '#20231f',
      border: '#d8dcd4',
      accent: '#365f46',
      accentContent: '#ffffff',
    },
    dark: {
      surface: '#20231f',
      content: '#f7f7f4',
      border: '#454b43',
      accent: '#9bc6a8',
      accentContent: '#172019',
    },
  },
} as const
A bounded source separates stable values from semantic values selected by appearance.

Values that don't belong in the five predefined categories need an explicit disposition. This example keeps durations in a custom category for retrieval by project code. Fonts would go through Tamagui's font configuration. Media conditions and component states would remain outside this source-to-token mapping.

Merge raw inputs before creating the Tamagui configuration

An existing project may already have tokens and themes that its components require. A top-level spread followed by tokens: mappedTokens or themes: mappedThemes would replace those complete objects. To preserve them, merge the raw input for every affected token category and theme first. Then call createTokens and createTamagui with the merged results.

import { createTamagui, createTokens } from 'tamagui'
import { portableSource } from './portable-source'
import {
  projectConfigRest,
  projectThemeInput,
  projectTokenInput,
} from './project-config-input'

const mergedTokenInput = {
  ...projectTokenInput,
  space: {
    ...projectTokenInput.space,
    ...portableSource.static.space,
  },
  size: {
    ...projectTokenInput.size,
    ...portableSource.static.size,
  },
  radius: {
    ...projectTokenInput.radius,
    ...portableSource.static.radius,
  },
  zIndex: {
    ...projectTokenInput.zIndex,
    ...portableSource.static.zIndex,
  },
  duration: {
    ...projectTokenInput.duration,
    ...portableSource.custom.duration,
  },
}

const mergedThemeInput = {
  ...projectThemeInput,
  light: {
    ...projectThemeInput.light,
    ...portableSource.themes.light,
  },
  dark: {
    ...projectThemeInput.dark,
    ...portableSource.themes.dark,
  },
}

export const tokens = createTokens(mergedTokenInput)

export const tamaguiConfig = createTamagui({
  ...projectConfigRest,
  tokens,
  themes: mergedThemeInput,
})

declare module 'tamagui' {
  interface TamaguiCustomConfig extends typeof tamaguiConfig {}
}
A Tamagui v3 integration shape that merges affected raw categories and light and dark themes before constructing the configuration.

The merge order is a policy decision

This example gives the portable source precedence for the keys it defines. Reverse that order if approved project values must win. In either case, record the rule and review collisions instead of relying on an accidental spread order.

projectConfigRest represents the application's already valid non-token configuration, including its fonts, media queries, animations, shorthands, and settings. projectTokenInput and projectThemeInput are the raw authored inputs used before createTokens and createTamagui. Keeping them separate avoids the false impression that replacing the final tokens or themes object preserves the values inside it.

The fixture also avoids older access patterns. In Tamagui v3, getTokens() uses unprefixed keys such as getTokens().radius.panel; the earlier prefixed copy option is removed. Don't build runtime behavior around removed relative token stepping. Resolve the named value the component actually needs.

Connect the values to a named consumer

Configuration availability is only one handoff. The component still has to reference the intended names. AccountSummarySurface below consumes the supplied static panel, section, and control tokens, along with the supplied surface, border, and content theme roles. Its operation and cross-platform result remain unverified until the fixture runs in the consuming applications.

import { Text, Theme, View, styled } from '@tamagui/core'

export const AccountSummarySurface = styled(View, {
  name: 'AccountSummarySurface',
  backgroundColor: 'surface',
  borderColor: 'border',
  borderWidth: 1,
  borderRadius: 'panel',
  padding: 'section',
  gap: 'control',
})

export const AccountSummaryText = styled(Text, {
  name: 'AccountSummaryText',
  color: 'content',
})

export function AccountSummaryFixture({
  mode,
}: {
  mode: 'light' | 'dark'
}) {
  return (
    <Theme name={mode}>
      <AccountSummarySurface>
        <AccountSummaryText>Available balance</AccountSummaryText>
        <AccountSummaryText>EUR 2,480</AccountSummaryText>
      </AccountSummarySurface>
    </Theme>
  )
}
The named consumer references the mapped static tokens and semantic theme roles. This is an implementation fixture, not a reported test result.

Under Tamagui's documented behavior, a missing theme key may fall back to a same-named color token. That can help when the value is intentionally mode-independent, but the fallback only establishes which value resolved. It doesn't establish that the color suits every surface or that the rendered component meets a visual or accessibility requirement.

Keep package provenance with the mapping

A shared design-system package adds more handoffs between the adapter and the screen. Record them together so you can tie a mismatch to the source, built package, consuming import, or active theme. Tamagui's package guide covers dedicated modules, component exports, builds, compiler discovery, and consumer testing. The exact bundler setup still depends on the installed Tamagui version and project toolchain.

{
  "source": {
    "id": "project-authored-account-summary",
    "revision": "example-1",
    "file": "packages/design-system/src/portable-source.ts"
  },
  "adapter": {
    "file": "packages/design-system/src/portable-mapping.ts",
    "revision": "record-the-reviewed-commit"
  },
  "configuration": {
    "file": "packages/design-system/src/tamagui.config.ts",
    "export": "tamaguiConfig"
  },
  "package": {
    "name": "@example/design-system",
    "versionOrRevision": "record-the-built-identity",
    "configEntry": "@example/design-system/config",
    "componentEntry": "@example/design-system/components"
  },
  "compilerDiscovery": {
    "expectedPackage": "@example/design-system",
    "observed": null
  },
  "consumer": {
    "application": "customer-app",
    "configImport": "@example/design-system/config",
    "component": "AccountSummarySurface",
    "themes": ["light", "dark"]
  }
}
A provenance record for handoffs that can change independently. Observation fields remain open until inspected.

A successful TypeScript import proves neither that the compiler discovered the shared component package nor that the application loaded the intended build revision. Record each as a separate check. Follow the official package instructions for the project's actual Webpack, Next.js, or React Native setup.

Verify web and native through different routes

Use one semantic expectation, but collect platform-specific evidence. On web, inspect Tamagui Variable metadata, the emitted CSS variable, the active theme scope, and the component's computed style. On native, inspect the active theme, imported component identity, and the raw value or resolved style that the component receives. Keep visual and accessibility observations in the same case record, but don't substitute them for value-resolution evidence.

Expected resolutionInspectFail when
Web, lightsurface #f7f7f4; panel radius 18; section padding 24Active light theme, Variable metadata, emitted CSS declarations, and computed component stylesThe active scope, resolved variable, or computed value differs from the recorded expectation
Web, darksurface #20231f; radius 18; padding 24The same consumer after changing only the Theme name to darkThe background stays on the light value or static geometry changes
Native, lightLight surface value with radius 18 and padding 24Provider configuration, active Theme name, package identity, and resolved component styleA local value wins, the wrong theme is active, or a resolved value differs
Native, darkDark surface value with the same static geometryThe same fixture under the dark Theme, with platform and operating-system version recordedThe semantic role does not change or the observation cannot be tied to the recorded package
Rendered reviewThe actual content and supported states remain usable under the recorded conditionRendered content, relevant interaction states, visual inspection, and the project's chosen accessibility checksResolution passes but a separately required visual or accessibility condition fails
Unexecuted acceptance cases for the AccountSummarySurface fixture.

Change one condition at a time

Keep the component, content, package revision, and platform fixed while changing only the Theme name. Semantic colors should follow the selected mode, while static spacing and radius stay fixed.

Write the expected values before running the fixture, then add observations without rewriting the expectation. A browser may normalize color notation, so compare resolved colors instead of demanding the authored hex string verbatim. Native has no CSS variable to inspect. Record the raw resolved value and the component property that received it.

Resolution and rendered acceptance answer different questions. Resolution checks whether the named role reached the named property. Rendered acceptance checks the actual component, content, mode, state, and platform. Agreement between web and native doesn't by itself prove readability, focus visibility, status meaning, performance, or accessibility.

Inspect the upstream system before writing the adapter

A complete kit can supply portable decisions for colors, typography, spacing, layout, motifs, and usage guidance. The consuming project still owns the Tamagui mapping, package delivery, component behavior, and platform checks.

Diagnose the first divergence

When the fixture differs from the expectation, inspect the chain in authority order. Stop at the first mismatch. A local component override may hide the visible symptom while other consumers remain exposed to the same source, adapter, package, or theme error.

  1. Portable source: confirm the source identity, revision, role, mode, and expected value.
  2. Adapter mapping: confirm that stable values, theme roles, custom categories, fonts, and application behavior were routed to their intended owners.
  3. Raw configuration merge: confirm that every affected category and both theme objects contain the required existing and portable keys before construction.
  4. Constructed Tamagui configuration: confirm unprefixed token keys and the expected light and dark theme roles.
  5. Package build: confirm that the inspected adapter revision is present in the built package identity.
  6. Application import: confirm that the app loads the intended configuration and component entries.
  7. Compiler discovery: confirm the shared component package using the documented setup for the actual bundler.
  8. Theme scope: confirm that AccountSummarySurface is inside the intended light or dark Theme.
  9. Component reference: confirm that the consumer uses surface, border, panel, section, and control without an unintended local replacement.
  10. Platform output: compare web computed styles or native resolved values with the written matrix, then record visual and accessibility observations separately.

Make the retention decision

Identity Forge can supply a portable design kit and DTCG token output as upstream input, but it has no verified direct Tamagui export. The consuming project owns the adapter, configuration merge, package delivery, component contract, and cross-platform evidence.

Retain the mapping only when the same named semantic role reaches AccountSummarySurface in both light and dark, its static token values stay as expected, and every web or native platform the project claims to support has a recorded observation that matches the acceptance matrix.

Sources

  • Tokens - Tamagui: Tamagui documents createTokens, Variable metadata, unprefixed getTokens access in v3, custom token categories, theme fallback, component consumption, and web and native value representations.
  • Design system - Tamagui: Tamagui separates tokens, themes, fonts, and media queries, and documents category-based property resolution, numeric pixel values, and the px helper.
  • Tokens - Tamagui default scale: Tamagui documents its coordinated default size, space, radius, and font scale while allowing applications to define other names and values.
  • Design Systems - Tamagui: Tamagui documents dedicated design-system packages, component exports, package builds, compiler discovery, and testing from a consuming application.
  • Learn Tamagui: This community tutorial covers practical monorepo configuration, tokens, themes, palettes, and component sizing decisions.
  • Identity Forge: Identity Forge provides complete design kits and portable implementation artifacts that can serve as upstream input to a project-owned framework adapter.
  • Semantic color tokens explained: Identity Forge describes semantic colors as stable role names whose resolved values can differ between light and dark modes.