Tamagui
Universal UI for React Native and web
Tamagui is a style library and UI kit that works across React and React Native. It provides a typed styling system, an optimizing compiler, and a complete set of components - all designed to share code between platforms without sacrificing performance.
Why Tamagui
Cross-platform styling usually means runtime overhead on web or limited capabilities on native. Tamagui solves this with a compiler that outputs optimized, platform-specific code from a single source.
- Zero runtime overhead - Compiler extracts styles to atomic CSS on web
- Full React Native API - Every style property works on both platforms
- Type-safe tokens - Colors, spacing, and typography with full IntelliSense
- Theme system - CSS variables on web, no re-renders on theme change
Core Concepts
Styled Components
Create components with the styled() function:
Design Tokens
Define your design system once:
Access tokens with $ prefix: bg=“$background”, p=“$4”, rounded=“$3”.
Themes
Themes cascade through your app via CSS variables:
Theme changes don’t trigger re-renders - they update CSS variables.
Responsive Styles
Media queries compile to atomic CSS:
Or use the hook for JS logic:
The Compiler
Tamagui’s compiler transforms styled components at build time:
Input:
Web output:
The compiler:
- Extracts styles to atomic CSS classes
- Flattens nested styled components
- Eliminates runtime style computation
- Tree-shakes unused styles
Takeout Integration
Takeout configures Tamagui with:
- Dual animation drivers - CSS for static pages, spring physics for app pages
- Theme-conditional styles -
$theme-darkand$theme-lightprops - Group selectors -
$group-button-hoverfor parent-scoped states - Pre-built components - Buttons, inputs, modals, and more
Basic Usage
Learn More
Edit this page on GitHub.