Introduction

Tamagui provides universal styling and UI components for React. All features work consistently across React Native and web.

  • @tamagui/core is the base style library. It provides a web-aligned universal style system with SSR support, typed tokens, and optimized runtime performance across web and native.
  • @tamagui/static is an optimizing compiler that extracts style props into atomic CSS and flattens component trees at build time.
  • Tamagui Components provides accessible, composable UI primitives for web and native, including the Adapt primitive for responsive and platform-specific presentations.

Install

Add Tamagui to an app you already have: the config, the provider, and the plugin for your bundler.

Quick start

Start from a template with everything already wired up.

npm create tamagui@latest

Two ways to write styles

Tamagui ships two styling frontends. Both compile to the same atomic CSS on web and the same native styles on iOS and Android, and both accept the same tokens, themes, and media queries.

Style props on View and Text are the default. They are typed and compile to atomic CSS on web or native styles on iOS and Android:

import { Text, View } from 'tamagui'
export const Card = () => (
<View padding="4" borderRadius="lg" backgroundColor="background">
<Text fontSize="6">Hello</Text>
<Text color="color-11 hover:color-12">World</Text>
</View>
)

Tailwind classes on className are the other option, for teams who already think in utilities:

import { Text, View } from '@tamagui/tailwind'
export const Card = () => (
<View className="p-4 rounded-lg bg-background">
<Text className="text-2xl">Hello</Text>
<Text className="text-color-11 hover:text-color-12">World</Text>
</View>
)

The choice is per import path, so one app can use both. Read Components for the style prop path and Tailwind for the utility path.

Why a compiler

Cross-platform development often involves trade-offs between native feel, code reuse, and performance. React Native shares logic across platforms, but on web, styling in JavaScript can mean heavy runtime overhead and larger bundles.

Tamagui resolves this with @tamagui/static, an optimizing compiler that:

  • Extracts every style prop, media query, theme value, and interactive state into atomic CSS.

  • Removes most inline styles through partial evaluation and hoisting.

  • Flattens styled components into a plain div or View, so the tree gets shallower.

  • Turns useMedia and useTheme expressions into media queries and CSS variables.

Here is what that looks like in code:

Use inline style props or styled():

Input
import { View, Text, styled } from '@tamagui/core'
import { Heading } from './Heading'
const App = (props) => (
<View px="10px gtSm:30px" width={550}>
<Heading size={props.big ? 'large' : 'small'}>Lorem ipsum.</Heading>
</View>
)
const Heading = styled(Text, {
render: 'h1',
color: 'green',
backgroundColor: 'background',
variants: {
size: {
large: {
fontSize: 22,
},
small: {
fontSize: 16,
},
},
},
})

Get back perfectly optimized DOM on web (or View/Text on native).

Output
export const App = props => <div className={_cn}>
<h1 className={_cn2 + (_cn3 + (props.big ? _cn4 : _cn5))}>
Lorem ipsum.
</h1>
</div>
const _cn5 = " _fos-16px"
const _cn4 = " _fos-22px"
const _cn3 = " _bg-180kg62 _col-b5vn3b _mt-0px _mr-0px _mb-0px _ml-0px _ww-break-word _bxs-border-box _ff-System _dsp-inline "
const _cn2 = " font_System"
const _cn = " _fd-column _miw-0px _mih-0px _pos-relative _bxs-border-box _fb-auto _dsp-flex _fs-0 _ai-stretch _w-550px _pr-1aj14ca _pl-1aj14ca _pr-_gtSm_lrpixp _pl-_gtSm_lrpixp"

The Text became a p and the YStack became a div. On native the same pass produces Text and View. Flattening is where most of the speed comes from. Across real apps around a third to a half of components flatten, and the result on web is close to hand-written CSS. On native the output is within a few percent of hand-optimized React Native, with the whole feature set intact.

Everything still works at runtime. The compiler is an optimization you can add later, and a component it cannot optimize simply renders the normal way. See Benchmarks for numbers and Compiler installation to turn it on.

Where to go next

  • Installation sets up a project or hands the job to a coding agent.
  • Components covers html.*, View, Text, and how they render on each platform.
  • Styling explains style props, conditional values, and states.
  • Design system introduces tokens, themes, and fonts.
  • Tailwind covers the utility class frontend.

Highlights

  • Core depends only on React and supports the full React Native View and Text APIs, style props, styled(), hooks, and typed design tokens in ~28KB on web.

  • The optimizing compiler extracts styles into atomic CSS and flattens styled components at build time.

  • Every feature works with or without the compiler, with graceful fallback to runtime resolution.

  • useTheme and useMedia hooks provide fine-grained subscription updates.

  • Unstyled and styled variants are available for all components.

Community

Join us on:

Credits

A big thanks to:

  • Stitches for the variants pattern.
  • JSXStyle for providing the original version of the compiler.
  • Modulz for Radix, which inspired many of our component APIs, and for the initial structure of this website.
  • Framer Motion for the AnimatePresence implementation.