Theming
Change brand colors, radii, shadows and fonts without touching a component.
Components never name a color. They name a role — bg-weak-50,
text-sub-600, border-soft-200, bg-primary-base — and each role is a CSS
variable. Theming tdpxl means changing what those variables hold. The role scale
itself is explained in Tokens.
The roles
| Family | Roles | Used for |
|---|---|---|
| Surfaces | white-0, weak-25, weak-50, soft-200, sub-300, surface-800, strong-950 | Page, raised and sunken surfaces, dividers, inverted fills |
| Text | strong-950, sub-600, soft-400, disabled-300, white-0 | Headings, body, supporting detail, inactive text, text on fills |
| Brand | primary-base, primary-dark, primary-darker, primary-alpha-10, primary-alpha-16, primary-alpha-24 | Primary actions, hover/pressed steps, translucent fills and focus rings |
| States | success-*, warning-*, error-*, information-*, away-*, faded-*, highlight-* | Each with lighter (fill), light (border), base (solid) and dark (text on the fill) |
Every role exists in both :root (light) and .dark, with the same name.
In your project: edit the CSS variables
After init, the roles live in your stylesheet, inside the section between
tdpxl:theme:start and tdpxl:theme:end. That section is managed:
npx @tdpxl/cli update theme brings in a new registry version, merging edits you
made inside it, and add theme --overwrite resets it. Put your changes after
the end marker instead, so an update never has to merge them. A later rule with the same
selector wins:
/* tdpxl:theme:end */
:root {
--primary-base: oklch(0.55 0.2 300);
--primary-dark: oklch(0.47 0.18 300);
--primary-darker: oklch(0.39 0.15 300);
--primary-alpha-10: oklch(0.55 0.2 300 / 10%);
--primary-alpha-16: oklch(0.55 0.2 300 / 16%);
--primary-alpha-24: oklch(0.55 0.2 300 / 24%);
}
.dark {
--primary-base: oklch(0.72 0.17 300);
--primary-dark: oklch(0.8 0.13 300);
--primary-darker: oklch(0.87 0.09 300);
--primary-alpha-10: oklch(0.72 0.17 300 / 10%);
--primary-alpha-16: oklch(0.72 0.17 300 / 16%);
--primary-alpha-24: oklch(0.72 0.17 300 / 24%);
}Three things to keep in mind:
- Set both schemes. A role changed only in
:rootkeeps its old dark value. - The alpha roles are literal values. In the installed CSS,
--primary-alpha-*are written out, not derived from--primary-base. Change them together, or define them withcolor-mix(in oklch, var(--primary-base) 16%, transparent). - Check contrast.
white-0text sits onprimary-base, and each state'sdarktext sits on itslighterfill. Normal text needs 4.5:1 in both themes.
There is no need for @theme changes: @theme inline already points
--color-primary-base at var(--primary-base), so every utility follows.
In the tdpxl repository: edit lib/tokens.ts
If you maintain a fork of the registry, the CSS above is generated, and editing
it by hand would be lost on the next build. The source of truth is
lib/tokens.ts:
RAMPS— seven rawoklchramps (gray,blue,green,orange,yellow,red,purple), twelve steps each, built from one lightness curve.SEMANTIC_LIGHTandSEMANTIC_DARK— each role pointing at a ramp step, such as"primary-base": "blue.700", or at a literal value.primary-alpha-10/16/24are derived fromprimary-baseat build time.RADIIandSHADOWS— see below.
pnpm tokens:build # app/tokens.css for the site and Storybook
pnpm registry:build # the theme item consumers installChanging the brand hue is one edit to the blue ramp, or to the brand roles'
references. No component changes.
Radii
| Utility | Value |
|---|---|
rounded-4 | 0.25rem |
rounded-6 | 0.375rem |
rounded-8 | 0.5rem |
rounded-10 | 0.625rem |
rounded-12 | 0.75rem |
rounded-16 | 1rem |
rounded-20 | 1.25rem |
rounded-full | 9999px |
They are --radius-* variables inside @theme inline. To make the whole system
rounder or squarer, override them in your own @theme block after the managed
section, for example @theme { --radius-10: 0.75rem; }.
Shadows
shadow-regular-xs, shadow-regular-sm, shadow-regular-md and
shadow-regular-lg for elevation; shadow-button-primary-focus and
shadow-button-error-focus for focus rings; shadow-toggle-switch for the
switch thumb. The focus shadows reference --white-0, --primary-alpha-24 and
--error-base, so they follow your colors and the dark scheme.
Typography
Components pick a typographic role, never a loose size. The theme adds these
utilities with @utility:
| Utility | Size / line height | Weight |
|---|---|---|
text-title-h1 | 3.5rem / 1 | 500 |
text-title-h4 | 2rem / 1.15 | 500 |
text-label-lg | 1.125rem / 1.5rem | 500 |
text-label-md | 1rem / 1.5rem | 500 |
text-label-sm | 0.875rem / 1.25rem | 500 |
text-label-xs | 0.75rem / 1rem | 500 |
text-paragraph-lg | 1.125rem / 1.75rem | — |
text-paragraph-md | 1rem / 1.5rem | — |
text-paragraph-sm | 0.875rem / 1.25rem | — |
text-subheading-xs | 0.75rem / 1rem, uppercase | 500 |
The cn() helper installed as utils teaches tailwind-merge that these are
font sizes, so cn("text-label-sm", "text-sub-600") keeps both classes.
Fonts
The theme's base styles set font-family: var(--font-sans) on body, but the
theme does not define --font-sans. That is deliberate: the font is your
brand decision and loading it is your framework's job. Until you set it, the
value comes from Tailwind's default theme, a system font stack.
To use your own font, define the variable in your @theme. With next/font:
// app/layout.tsx
import { Inter } from "next/font/google"
const inter = Inter({ subsets: ["latin"], variable: "--font-inter" })
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en" className={inter.variable}>
<body>{children}</body>
</html>
)
}/* app/globals.css, outside the managed section */
@theme inline {
--font-sans: var(--font-inter), ui-sans-serif, system-ui, sans-serif;
}In Vite, load the font with @font-face or a package such as Fontsource and
set --font-sans the same way.