Tamagui Tailwind
Tailwind CSS utility authoring for Tamagui web and native
Tamagui Tailwind brings utility classes in className to web, iOS, and
Android through the Tamagui compiler.
Tailwind CSS is a trademark of Tailwind Labs Inc. Tamagui is not affiliated with or endorsed by Tailwind Labs.
Installation
Install @tamagui/tailwind and @tamagui/config:
yarn
npm
bun
pnpm
Basic usage
Import components directly from @tamagui/tailwind:
The styling frontend is selected by import path. There is no global configuration toggle.
Semantic elements
@tamagui/tailwind also exports html, the same set of semantic elements as html from tamagui, built on the Tailwind frontend. Same tags, same element defaults, and a class string rather than style props as the styling input:
Every tag renders a real element on web and its React Native equivalent on native, exactly as the tamagui html does. It composes with styled() too:
Vite integration
Applications authoring with @tamagui/tailwind use the Vite plugin from @tamagui/tailwind/vite:
The plugin wraps the core Tamagui compiler and scans JSX sources for utility candidates.
Web and native resolution
Tamagui Tailwind components render through the same core engine as standard Tamagui components:
- On web: The compiler extracts claimed utilities into atomic CSS classes at build time.
- On native: The shared renderer resolves the utility classes into React Native styles at runtime.
Both platforms share the same config, design tokens, themes, media queries, accessibility props, and animation drivers.
Modifiers
Tamagui Tailwind supports standard modifiers:
Pseudo states
Supported state modifiers include hover:, press:, focus:, focus-visible:, and disabled:.
Breakpoints
Breakpoint prefixes (e.g. sm:, md:, lg:, xl:, max-sm:) map to the media query definitions in your Tamagui config.
Platform modifiers
Use web:, native:, ios:, and android: to apply platform-specific utilities.
Group and container queries
Mark ancestors with group or @container / container, then apply group-hover: or @sm: on children.
Arbitrary values
Pass arbitrary values inside square brackets:
Tamagui normalizes arbitrary values for cross-platform safety:
- Unitless numbers (such as
z-[400]) and pixel lengths (such asp-[18px],text-[14px]) resolve to numeric values on native. React Native requires numbers for layout and typography props. - CSS units and functions (such as
%,rem,calc(),var(), hex colors) stay strings.
Tokens and color opacity
Utilities for color, radius, size, and spacing resolve against your Tamagui config tokens:
bg-blue-500resolves to theblue-500color token.rounded-lgresolves to thelgradius token.p-4resolves to the4space token.
Color utilities support opacity modifiers:
The opacity suffix lowers to CSS color-mix on web and RGBA colors on native.
Class-first styled()
Use styled() from @tamagui/tailwind to create reusable components with class-based variants:
Variant values are class strings. The resulting component accepts className and its declared variant props.
Mixing with Tamagui components
You can mix @tamagui/tailwind components and standard tamagui components within the same application:
Each component retains its authoring syntax. Both resolve through the same runtime and theme context.
Utility coverage
Claimed utilities are parsed by @tamagui/style-grammar. They compile to atomic CSS on web and resolve to React Native styles on iOS and Android.
Claimed cross-platform utilities
- Sizing:
w-*,h-*,size-*(width and height),min-w-*,max-w-*,min-h-*,max-h-*, fractions (w-1/2), keywords (full,auto,screen,min,max,fit). - Spacing:
p,pt,pr,pb,pl,px,py,m,mt,mr,mb,ml,mx,my,gap-*,gap-x-*,gap-y-*. - Flex and Alignment:
flex,flex-1,flex-auto,flex-initial,flex-none,flex-row,flex-col,flex-wrap,flex-wrap-reverse,grow,shrink,items-*,justify-*,content-*,self-*. - Typography:
text-sm(font size tokens),text-white(palette and theme colors),text-center/left/right/justify/start/end(alignment),text-[14px](arbitrary size),text-[#fff](arbitrary color),font-boldand named weights,font-sans/serif/monoand configured font families,leading-*(line height),tracking-*(letter spacing),italic/not-italic,uppercase/lowercase/capitalize/normal-case,underline/line-through/no-underline. - Color:
bg-*,color-*,text-*(colors),border-*(color), opacity suffix/50(such asbg-blue-500/50). - Radius:
rounded-*,rounded-t/r/b/l-*,rounded-tl/tr/bl/br-*(includingxl,lg,full). - Borders:
border(1px default),border-4,border-t/r/b/l-*,border-x/border-y(width and color). - Positioning:
relative,absolute,fixed,sticky,inset-*,inset-x-*,inset-y-*,top-*,right-*,bottom-*,left-*,z-*. - Transforms & Effects:
opacity-*,overflow-*,object-fit,pointer-events-*,rotate-*,scale-*,translate-x-*,translate-y-*,aspect-*,shadow-[…](arbitrary shadow), group and container markers (group,container="card",@container).
text-* utilities resolve in strict order: configured fontSize token first, then alignment keywords, then configured palette color.
Web-only passthrough
Classes that do not have a React Native style equivalent pass through to className on web. On native, unrecognized classes are dropped:
- CSS Grid & Columns:
grid-*,col-*,row-*,auto-cols-*,auto-rows-*,columns-*,break-* - Filters & Blurs:
backdrop-*,blur-*,brightness-*,contrast-*,grayscale-*,drop-shadow-* - Gradients & Blends:
from-*,via-*,to-*,bg-gradient-*,mix-blend-* - Child & Sibling Selectors:
space-x-*,space-y-*,divide-x-*,divide-y-* - Rings & Outlines:
ring-*,ring-offset-*,outline-*(useshadow-[…]for cross-platform shadow) - Web Chrome & Pseudo Elements:
cursor-*,select-*,appearance-*,resize-*,placeholder-*,caret-* - Arbitrary Selectors:
peer-*,has-*,data-*,aria-*,[&>*] - Keyframe Animations:
animate-*(use Tamagui’stransitionprop instead)