tdpxl

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

FamilyRolesUsed for
Surfaceswhite-0, weak-25, weak-50, soft-200, sub-300, surface-800, strong-950Page, raised and sunken surfaces, dividers, inverted fills
Textstrong-950, sub-600, soft-400, disabled-300, white-0Headings, body, supporting detail, inactive text, text on fills
Brandprimary-base, primary-dark, primary-darker, primary-alpha-10, primary-alpha-16, primary-alpha-24Primary actions, hover/pressed steps, translucent fills and focus rings
Statessuccess-*, 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 :root keeps 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 with color-mix(in oklch, var(--primary-base) 16%, transparent).
  • Check contrast. white-0 text sits on primary-base, and each state's dark text sits on its lighter fill. 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 raw oklch ramps (gray, blue, green, orange, yellow, red, purple), twelve steps each, built from one lightness curve.
  • SEMANTIC_LIGHT and SEMANTIC_DARK — each role pointing at a ramp step, such as "primary-base": "blue.700", or at a literal value.
  • primary-alpha-10/16/24 are derived from primary-base at build time.
  • RADII and SHADOWS — see below.
pnpm tokens:build     # app/tokens.css for the site and Storybook
pnpm registry:build   # the theme item consumers install

Changing the brand hue is one edit to the blue ramp, or to the brand roles' references. No component changes.

Radii

UtilityValue
rounded-40.25rem
rounded-60.375rem
rounded-80.5rem
rounded-100.625rem
rounded-120.75rem
rounded-161rem
rounded-201.25rem
rounded-full9999px

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:

UtilitySize / line heightWeight
text-title-h13.5rem / 1500
text-title-h42rem / 1.15500
text-label-lg1.125rem / 1.5rem500
text-label-md1rem / 1.5rem500
text-label-sm0.875rem / 1.25rem500
text-label-xs0.75rem / 1rem500
text-paragraph-lg1.125rem / 1.75rem—
text-paragraph-md1rem / 1.5rem—
text-paragraph-sm0.875rem / 1.25rem—
text-subheading-xs0.75rem / 1rem, uppercase500

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.

On this page