Guide · v0.13.8

Tailwind classes

Write Tailwind CSS utility classes on any element. There is no CSS and no DOM: each class list compiles to the element's native style when the JSX runs, so nothing needs to be installed or configured.

class and className

Every intrinsic element and every Tarve component accepts class (the HTML spelling) or className. Theme tokens such as bg-card, text-muted-foreground and border-border follow the active theme. Hover the button below: the playground runs the same renderer as a desktop window.

Native render. The live version loads when this comes into view.
card.tsx
<div class="flex flex-col gap-3 p-5 w-80 rounded-xl bg-card border border-border shadow-md">
  <span class="text-xs font-semibold uppercase tracking-wide text-muted-foreground">Starter plan</span>
  <span class="text-3xl font-bold text-foreground">$12<span class="text-sm font-normal text-muted-foreground"> / month</span></span>
  <span class="text-sm text-muted-foreground">Everything you need to ship a native app.</span>
  <div class="mt-2 px-4 py-2 rounded-md bg-primary text-primary-foreground text-sm font-medium text-center hover:bg-primary/90 active:scale-95 transition">
    Choose plan
  </div>
</div>;

tw() for style props

tw("…") returns the same Style object, for props that take a style rather than a class. It accepts several arguments and skips falsy ones, like clsx, so conditional classes read naturally.

Native render. The live version loads when this comes into view.
tw.tsx
import { Badge, Column, Text, tw } from "@tarve/core";

const active = true;

<Column style={tw("gap-2 p-4 w-80 rounded-xl border border-border bg-card", active && "ring-2 ring-primary/40")}>
  <Text style={tw("text-sm font-semibold text-foreground")}>tw() composes like clsx</Text>
  <Text style={tw("text-xs text-muted-foreground")}>Falsy arguments are skipped, later classes win.</Text>
  <Badge style={tw("self-start")}>{active ? "Active" : "Idle"}</Badge>
</Column>;

Which class wins

The rules are CSS's: later classes win, and an inline style wins over classes.

precedence.tsx
// later classes win, as in CSS
<div class="p-2 p-4" />                         // padding 16

// className comes after class; both may be given
<div class="bg-zinc-900" className="bg-zinc-800" />  // zinc-800

// an inline style wins over every class
<div class="p-4 text-red-500" style={{ foreground: "#fff" }} />

Variants

Native render. The live version loads when this comes into view.
states.tsx
<div class="flex flex-col gap-2 p-4 w-80 rounded-xl bg-zinc-900">
  <div class="group flex items-center gap-3 p-3 rounded-lg hover:bg-zinc-800 transition">
    <div class="size-9 rounded-full bg-linear-to-br from-pink-500 to-violet-600" />
    <div class="flex flex-col">
      <span class="text-sm font-medium text-zinc-100 group-hover:text-white">Hover the row</span>
      <span class="text-xs text-zinc-400 group-hover:text-pink-300">group-hover: restyles a child</span>
    </div>
  </div>
  <div class="px-3 py-2 rounded-md border border-zinc-700 text-sm text-zinc-300 hover:border-pink-500 active:bg-zinc-800 focus:ring-2 focus:ring-pink-500">
    hover:, active: and focus:
  </div>
  <div class="px-3 py-2 rounded-md text-sm text-emerald-300 bg-emerald-500/10 ring-1 ring-emerald-500/40">bg-emerald-500/10 · opacity modifiers</div>
</div>;
VariantWhen it applies
hover:, active:, focus:, focus-visible:, focus-within:, disabled:Native interaction states, animated by transition-* like CSS.
group + group-hover:Mark a parent with group; children restyle while the pointer is over it.
sm:, md:, lg:, xl:, 2xl:Tailwind's breakpoints (640, 768, 1024, 1280, 1536 px) measured against the window width; resizing re-renders only the subtrees that use them.
dark:Applies when the active theme's background is dark (darkTheme or your own dark theme).
first:, last:, odd:, even:Position among the siblings.

Variants nest in Tailwind's order: dark:md:hover:bg-zinc-800 works.

variants.tsx
<div class="flex flex-col md:flex-row gap-2">            // row from 768 px of window width
  <div class="p-2 odd:bg-muted even:bg-card first:rounded-t-lg last:rounded-b-lg" />
</div>

<div class="bg-white text-zinc-900 dark:bg-zinc-900 dark:text-zinc-100" />  // dark theme

Supported utilities

The vocabulary follows Tailwind CSS 4, and the test suite compares every class with the real Tailwind compiler.

GroupClasses
Layoutflex, grid, inline-flex, hidden, items-*, self-*, content-*, justify-*, place-*, gap-*, gap-x/y-*, space-x/y-*, grow, shrink, basis-*, order-*, grid-cols-*, col-span-*, relative, absolute, inset-*, top/right/bottom/left-*, start/end-*, z-*, overflow-*
Spacing & sizep-*, px/py/pt/pr/pb/pl-*, m-*, mx-auto, w-*, h-*, size-*, min/max-w-*, min/max-h-*: the 4 px scale, fractions (w-1/2), full, the container scale (max-w-md) and arbitrary values (w-[320px], h-[50%])
Colourbg-*, text-*, border-*, ring-*, outline-*, from/via/to-*: the full Tailwind 4 palette, white/black/transparent, theme tokens (bg-primary, text-muted-foreground, border-border…) and /opacity modifiers (bg-primary/10)
Typographytext-xs…9xl and text-sm/6, font-thin…black, font-sans/serif/mono, leading-*, tracking-*, text-left/center/right/justify, truncate, line-clamp-*, underline, line-through, uppercase/lowercase/capitalize, italic
Borders & effectsborder, border-x/t/…-*, rounded-*, rounded-t/tl/…-*, shadow-*, inset-shadow-*, text-shadow-*, ring-*, outline-*, opacity-*, blur-* (CSS filter), backdrop-blur-*, backdrop-saturate-* (backdrop blur)
Gradientsbg-linear-to-r, bg-linear-45, bg-radial, bg-conic, bg-gradient-to-* with from-*, via-*, to-* and their positions (from-10%)
Motiontransition, transition-*, duration-*, delay-*, ease-*, animate-spin, scale-*, translate-x/y-*, rotate-*, skew-*, origin-*
Interactioncursor-* (cursor-none hides it), select-none/text/all, pointer-events-none/auto, object-*, aspect-*

What has no native counterpart

Unknown classes are ignored rather than approximated, so a stray web-only class never breaks a layout.

Droppedinline, table and float layouts, fixed and sticky, min/max-content, viewport units, CSS filters (blur, grayscale, drop-shadow), blend modes, lists, columns, pseudo-elements (before:, placeholder:, selection:), print:, motion-*:, rtl:, peer-*, has-[], arbitrary properties and calc()
Approximatedinline-flex is flex, static is relative, space-x/y-* is a flex gap, ring-* and outline-* are both the outline, backdrop-* needs the D3D11 renderer (the others paint only the tint), ease-*/delay-* animate nothing without a duration