Configuration
Set up tokens, themes, fonts, media queries, shorthands, settings, and sizing.
Configuration connects your tokens, themes, media queries, animations, shorthands, settings, and sizing to every Tamagui component.
Start with @tamagui/config/v6 for default tokens,
Tailwind-aligned shorthands, and themes.
Create a tamagui.config.ts file:
yarn
npm
bun
pnpm
tamagui.config.ts
Pass the config export to a TamaguiProvider at
the root of your app:
That is a working setup. Import tamagui.config.ts once, near the root. Other files
reach the config through style props and hooks like useMedia and useTheme.
This guide imports from tamagui. If you only use the style library, swap the
imports for @tamagui/core, which is a strict subset.
The shape of createTamagui
createTamagui takes one object. Every key is optional. Here is a complete config
written from scratch, without the v6 preset, to show each concern in one place:
tamagui.config.ts
If using the compiler, your tamagui.config.ts is parsed at build-time. For this reason, we recommend keeping it relatively simple. Avoid importing heavy dependencies.
Where each concern lives
Each key of createTamagui has its own page. The sections below say what the key
does and where to read more.
TamaguiProvider
TamaguiProvider mounts the config at the root of your app. It also owns how the
generated CSS reaches the page in production, and the option to drop theme JS from
the client bundle. See TamaguiProvider.
Tokens
Tokens are static values with a name. They compile to CSS variables on web and are
available to every style prop. Create them with createTokens and pass them under
tokens. The categories size, space, radius, zIndex, and color map to
specific style properties, and you can add any category of your own. See
Tokens for how tokens resolve, custom categories, and the px
helper.
Font tokens
Fonts are tokens with structure. Each family carries its own size, line height,
weight, and letter spacing scales, created with createFont. Android needs the
face map to select font files by weight. See Fonts.
Themes
Themes sit one level above tokens. They hold values that change per subtree, most
often colors, and components read them by key. Sub-themes such as dark_blue fall
back to their parent. Custom variables merge into every base theme and can be
redefined for any subtree. See Defining themes
for the config shape, Themes for usage, and
Creating themes for generating full theme suites.
Media
The media object defines named media queries. Each name becomes a style prop key,
a useMedia key, and a group style key. Order matters. Later entries override
earlier ones. See useMedia.
Animations
Tamagui ships four animation drivers: CSS, React Native Animated, Reanimated, and
Motion. Pick one per platform and pass it under animations. See
Animations for the API and
Choosing an animation driver for setup and
per-platform swapping.
Shorthands
Shorthands map short prop names to style properties, so px can mean
paddingHorizontal. Config v6 ships Tailwind-aligned names. See
Shorthands.
Settings
Settings control type strictness, SSR behavior, theme class placement, and performance tradeoffs. A few more behaviors are set with environment variables. See Settings.
Sizing
Sizing is the shared control ladder: named rungs from xs to xl that every
sized control reads, with geometry derived from your font and space scales.
Spread defaultSizing and add rungs to grow the ladder. See
Sizing.