Tailwind setup
Shavin's tokens are CSS variables, exposed to Tailwind 3 and 4 as utilities like bg-surface and text-fg-subtle. npx @shavin/cli init sets this up; this page shows the main lines it adds. For what Shavin adds on top of Tailwind, and when plain Tailwind is enough, see Shavin and Tailwind CSS.
Tailwind 4
/* app/globals.css */
@import "tailwindcss";
@import "@shavin/ui/tokens.css";
@import "@shavin/ui/base.css" layer(base);
@import "@shavin/ui/theme-v4.css";
@source "../node_modules/@shavin/ui";tokens.css holds the variables. base.css sets the page defaults (body text and colour, the focus ring, selection, scrollbars) in Tailwind's base layer, so any utility you write wins over them. Projects that import styles.css (both in one file) keep working.
Tailwind 4 does not scan node_modules, so the @source line is needed for Shavin's own classes. Adjust the path relative to your CSS file.
With shadcn/ui
Shavin and shadcn/ui can share a Tailwind 4 project. Their variables don't overlap: Shavin's brand colour is --brand (bg-brand, text-brand-contrast), and shadcn keeps --accent, --primary, --border and --ring. Shavin's page defaults load in the base layer, so shadcn's utilities and base styles win over them:
/* app/globals.css */
@import "tailwindcss";
@import "./brand-tokens.css";
@import "@shavin/ui/tokens.css";
@import "@shavin/ui/base.css" layer(base);
@import "@shavin/ui/theme-v4.css";
@import "./brand-theme-v4.css";
@import "tw-animate-css";
@source "../node_modules/@shavin/ui";
/* shadcn/ui's @theme inline, :root and .dark blocks follow unchanged */Each library's components keep their own look: shadcn's buttons keep their focus ring and colours, and Shavin's keep theirs. shadcn's base styles set the page background and text colour. Both follow the .dark class, so one theme switcher (next-themes or Shavin's ThemeProvider) drives both. The names --radius-sm, --radius-lg and --radius-xl exist in both: shadcn's radius utilities keep shadcn's values, and Shavin's components keep Shavin's. Keep Shavin's lines after @import "tailwindcss": placed before it, Tailwind's default radius and easing values replace Shavin's. npx @shavin/cli init adds these lines there and leaves shadcn's own untouched. For how the two differ, and when shadcn/ui alone is the better fit, see Shavin and shadcn/ui.
Tailwind 3
// tailwind.config.ts
import type { Config } from "tailwindcss";
import shavinPreset from "@shavin/ui/tailwind-preset";
export default {
presets: [shavinPreset],
content: [
"./node_modules/@shavin/ui/**/*.{js,mjs,ts,tsx}",
"./src/**/*.{ts,tsx}",
],
} satisfies Config;Then import @shavin/ui/styles.css in your global CSS.
OKLCH colours
OKLCH gives smoother colour on wide-gamut screens. Run init --oklch, or import @shavin/ui/global-oklch.css instead of the RGB files (on Tailwind 4: tokens-oklch.css, base-oklch.css and theme-v4-oklch.css), and set colorSpace="oklch" on ThemeProvider.
Plain CSS and CSS Modules
The same variables work outside Tailwind and follow the theme and dark mode. In the default RGB mode they hold channel values, so wrap them in rgb():
.panel {
background: rgb(var(--bg-elevated));
border: 1px solid rgb(var(--hairline));
border-radius: var(--radius-panel);
}In OKLCH mode the variables hold complete colours: use var(--bg-elevated) directly.