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
refas 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.jsonand imported from one stylesheet with@import "tailwindcss".initstops on Tailwind v3. - A TypeScript path alias, such as
"@/*": ["./*"]intsconfig.json(ortsconfig.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 initinit 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/nodeReplace 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 initComponents 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- Detects the framework (Next.js, Vite or unknown) from
package.json. - Checks that Tailwind CSS is v4 and that a path alias exists.
- 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.cssandsrc/App.css. Pass--css <file>to choose another one; if none matches, it asks. - Writes
tdpxl.jsonwith the registry location, that stylesheet and the aliases forcomponents,ui,hooks,libandutils. See the tdpxl.json reference. - Installs two registry items:
utils(thecn()helper, withclsxandtailwind-merge) andtheme(the tokens, withtw-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 */:rootand.darkhold the semantic roles (weak-50,sub-600,primary-base,error-lighter…) as plain CSS variables. Dark mode only reassigns them.@theme inlineexposes each role to Tailwind as--color-<role>, which is what makes utilities such asbg-weak-50,text-sub-600orborder-soft-200exist, plus the radius (rounded-10) and shadow (shadow-regular-md) tokens.- Typography utilities such as
text-label-smandtext-paragraph-mdare added with@utility. @import "tw-animate-css"is inserted after your last existing@import, and@custom-variant darkis 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 sidebarThe 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.