Browse docs
Browse docs
Three steps. Two minutes. One working Button on screen.
You should already have a React app with Tailwind CSS configured. If you don't, set one up first — Vite + Tailwind is the fastest path:
pnpm create vite@latest my-app -- --template react-ts
cd my-app
pnpm add -D tailwindcss@^3 postcss autoprefixer
pnpm exec tailwindcss init -pRequired versions: React 18+ (19 supported), Tailwind CSS 3.x, TypeScript 5+ (for the typed token surface and component props).
pnpm add @dashforge/tw @dashforge/tw-theme @dashforge/tw-tokensThe three packages are versioned independently — you can upgrade tokens without touching components, or patch components without re-validating your theme. See each package's COMPAT.md for the compatibility matrix.
Add dashforgePreset() to your tailwind.config.js:
import { dashforgePreset } from '@dashforge/tw-theme';
/** @type {import('tailwindcss').Config} */
export default {
presets: [dashforgePreset()],
content: [
'./index.html',
'./src/**/*.{ts,tsx}',
// Scan the library's own emitted classes so JIT keeps them:
'./node_modules/@dashforge/tw/dist/**/*.{js,mjs}',
],
};What the preset does: it extends Tailwind's theme with the color scales (primary-500, success-600, etc.), the spacing scale, the radii and font sizes from @dashforge/tw-tokens — all of them mapped to CSS variables, not hardcoded values. That's what lets you flip the theme at runtime without rebuilding.
In your app root (typically main.tsx or App.tsx):
import { DashforgeTailwindProvider } from '@dashforge/tw-theme';
import './index.css'; // your Tailwind entry — must @tailwind base/components/utilities
export function App() {
return (
<DashforgeTailwindProvider>
<YourApp />
</DashforgeTailwindProvider>
);
}The provider:
<html> so every Dashforge component (and your own utilities, if you reference our tokens) reads them.dark class on <html> when the runtime mode flips to dark. Tailwind's dark: variant lights up.localStorage (key: dashforge-tw-mode).Drop a <Button> somewhere and confirm it paints:
import { Button } from '@dashforge/tw';
export function Hello() {
return (
<div className="p-8">
<Button color="primary">It works</Button>
</div>
);
}If you see a primary-colored button with a hover ring, you're done. If you see an unstyled <button>, jump to Troubleshooting — the most likely cause is the missing content entry for node_modules/@dashforge/tw/dist in step 2.