The language
Styling
Style with Tailwind-style utility classes in className. If you know Tailwind, you know most of this already. The difference is what a class does.
A class sets a prop
There's no stylesheet behind className. Each class is shorthand for a widget prop: p-6 sets the container's padding to 24px, rounded-xl its corner radius, text-lg the text's font size. Open the properties panel after applying and you'll see those values there, and the next time the code is printed, the props come back as classes.
<Container className="p-6 bg-white rounded-xl border border-gray-200 shadow-md">
<Text className="text-lg font-semibold text-gray-900 truncate">Weekend bundle</Text>
</Container>So a class only works on a widget that has the matching prop. Rounded corners on a Container are fine; a font weight on an Image is an error:
ErrorImage has no font weight
className only goes on widgets. It's usually a plain string; use backticks to span lines or switch classes on your data.
What's supported
| Group | Examples | Sets |
|---|---|---|
| Spacing | p-4px-6pt-2m-0mx-auto-mt-2 | padding, margin (1 unit = 4px) |
| Size | w-fullh-64size-10min-h-[400px]max-w-[520px]h-[55vh] | width, height, min/max |
| Flex & grid | gap-4gap-x-6justify-betweenitems-centergrowflex-nonegrid-cols-3col-span-2col-span-full | spacing, alignment, growth, columns, spans |
| Position | top-2left-2inset-0inset-x-4 | offsets of a Positioned |
| Colour | bg-whitebg-gray-100bg-primarybg-[#0f766e]bg-black/50 | background |
| Border | borderborder-2border-gray-200rounded-xlrounded-full | border width, colour, corner radius |
| Effects | shadow-mdshadow-noneopacity-40 | shadow (elevation), opacity |
| Type | text-smtext-2xltext-[28px]font-semiboldleading-tighttracking-wideitalicunderlineline-through | size, weight, line height, letter spacing, decoration |
| Text colour & layout | text-gray-900text-whitetext-centertruncateline-clamp-2whitespace-nowrap | colour, alignment, overflow, wrapping |
| Media | aspect-squareaspect-videoaspect-[4/5]object-coverobject-contain | aspect ratio, image fit |
| Visibility | hiddenblock | show or hide (usually per breakpoint) |
Spacing, font sizes, radii, shadows and colours follow Tailwind's scales: p-4 is 16px, text-sm is 14px, and gray-500 is Tailwind's gray-500.
Exact values
Square brackets take any value when the scale doesn't have the one you need:
<Text className="text-[28px] leading-[1.2] tracking-tight text-[#1f2937] max-w-[520px]">
Made in Durban, worn everywhere
</Text>Theme colours
Four colour names follow the store's theme instead of a fixed value: primary, secondary, accent and text-color. Use them with bg-, text- and border-. When the merchant changes their theme colours, everything using these names changes too.
<Container className="py-3 px-4 bg-primary">
<Text className="text-sm font-medium text-white text-center">
Order before 2pm for same-day dispatch
</Text>
</Container>The style prop
Text styles that have no utility class (a specific font family, an exact letter spacing) go in style, an object of text-style fields. Classes and style combine.
<Text
className="text-5xl text-gray-900"
style={{ fontFamily: "Fraunces, serif", fontWeight: "700", letterSpacing: "-0.02em" }}
semanticsTag="h1"
>
The summer collection
</Text>Headings follow the theme's heading font unless you set fontFamily yourself.
Not supported
Only breakpoint prefixes work (see Responsive design). State prefixes like hover: and focus: aren't supported. For hover effects, use props built for them, such as an Image's hoverZoom.
<Container className="bg-white hover:bg-gray-100" />Error"hover:" isn't supported yet β only breakpoints (sm: md: lg: xl: 2xl:)