tdpxl

Installation

Set up a Next.js or Vite project, run init, and add your first component.

tdpxl is not an npm dependency of your app. The @tdpxl/cli command copies each component's source into your project, together with the registry items and npm packages it imports. From then on the files are yours.

Requirements

  • React 19 or later. React 18 is not supported: components receive ref as a regular prop, which React 18 drops.
  • Next.js 15.5+ or 16 (App Router), or Vite 8 with @vitejs/plugin-react; React Router 8 works in a Vite project.
  • Tailwind CSS v4, listed in package.json and imported from one stylesheet with @import "tailwindcss". init stops on Tailwind v3.
  • A TypeScript path alias, such as "@/*": ["./*"] in tsconfig.json (or tsconfig.app.json). The CLI resolves every destination folder through it.
  • Node.js 20.9 or later (20, 22 and 24 are tested) to run the CLI.

Every combination above is installed and built from scratch in CI with a representative set of components, a chart and a block.

Next.js

create-next-app already produces a project that meets every requirement when you accept Tailwind CSS and the default @/* alias:

npx create-next-app@latest my-app
cd my-app
npx @tdpxl/cli init

init finds app/globals.css (or src/app/globals.css) because it imports Tailwind. Blocks are written into your App Router directory, app/ or src/app/.

Vite

Start from the React + TypeScript template and add Tailwind v4 with its Vite plugin:

npm create vite@latest my-app -- --template react-ts
cd my-app
npm install tailwindcss @tailwindcss/vite
npm install -D @types/node

Replace the contents of src/index.css with:

@import "tailwindcss";

Add the alias to both tsconfig.json and tsconfig.app.json, so the editor and the CLI can resolve it:

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": { "@/*": ["./src/*"] }
  }
}

Then teach Vite the same alias and register the Tailwind plugin in vite.config.ts:

import path from "node:path"
import tailwindcss from "@tailwindcss/vite"
import react from "@vitejs/plugin-react"
import { defineConfig } from "vite"
 
export default defineConfig({
  plugins: [react(), tailwindcss()],
  resolve: {
    alias: { "@": path.resolve(__dirname, "./src") },
  },
})

Now run:

npx @tdpxl/cli init

Components land in src/components/ui/, hooks in src/hooks/, cn() in src/lib/utils.ts. Blocks are written for the Next.js App Router; in a Vite project they go to src/components/<route>/ instead, and the authentication blocks will not compile there because they import next/link. See Blocks.

What init does

npx @tdpxl/cli init
  1. Detects the framework (Next.js, Vite or unknown) from package.json.
  2. Checks that Tailwind CSS is v4 and that a path alias exists.
  3. Finds the stylesheet that imports Tailwind among app/globals.css, src/app/globals.css, src/index.css, src/styles/globals.css, styles/globals.css, src/globals.css and src/App.css. Pass --css <file> to choose another one; if none matches, it asks.
  4. Writes tdpxl.json with the registry location, that stylesheet and the aliases for components, ui, hooks, lib and utils. See the tdpxl.json reference.
  5. Installs two registry items: utils (the cn() helper, with clsx and tailwind-merge) and theme (the tokens, with tw-animate-css).

If tdpxl.json already exists, init asks before replacing it; --force replaces it, together with the theme section.

What changes in your CSS

The theme item never touches what you wrote. It appends one managed section to the stylesheet, delimited by two comments:

@import "tailwindcss";
@import "tw-animate-css";
 
@custom-variant dark (&:is(.dark *));
 
/* tdpxl:theme:start … */
 
:root {
  --white-0: #ffffff;
  --strong-950: oklch(0.185 0.0084 264);
  --primary-base: oklch(0.468 0.1716 264);
  /* …every semantic role, light values */
}
 
.dark {
  --white-0: oklch(0.185 0.0084 264);
  /* …the same roles, dark values */
}
 
@theme inline {
  --color-white-0: var(--white-0);
  --color-sub-600: var(--sub-600);
  /* …one --color-<role> per role, then --radius-* and --shadow-* tokens */
}
 
@layer base {
  /* border color, body background/text/font, focus-visible outline */
}
 
@utility text-label-sm {
  /* …typography utilities */
}
 
/* tdpxl:theme:end */
  • :root and .dark hold the semantic roles (weak-50, sub-600, primary-base, error-lighter…) as plain CSS variables. Dark mode only reassigns them.
  • @theme inline exposes each role to Tailwind as --color-<role>, which is what makes utilities such as bg-weak-50, text-sub-600 or border-soft-200 exist, plus the radius (rounded-10) and shadow (shadow-regular-md) tokens.
  • Typography utilities such as text-label-sm and text-paragraph-md are added with @utility.
  • @import "tw-animate-css" is inserted after your last existing @import, and @custom-variant dark is added only if the file does not already declare one.

Later, npx @tdpxl/cli update theme brings in a new theme version and only ever touches the text between the markers (edits you made there are merged). Put your own overrides outside them; see Theming. Dark mode is a .dark class on an ancestor, usually <html>; see Dark mode.

Add components

npx @tdpxl/cli add button
npx @tdpxl/cli add card dialog sidebar

The CLI resolves each item's registry dependencies, writes every file, rewrites the internal imports to your aliases and installs the npm packages your package.json does not have yet, with the package manager your lockfile indicates. Then import the component from where it landed:

import { Button } from "@/components/ui/button"
 
export function Save() {
  return <Button intent="primary">Save</Button>
}

npx @tdpxl/cli list shows everything the registry offers. Every flag is described in CLI.

Each install is recorded in tdpxl-lock.json, and the registry source it came from is kept in .tdpxl/base/. Commit both: they let npx @tdpxl/cli diff and npx @tdpxl/cli update bring in new versions without losing your edits. See Staying up to date.

On this page