Installation
Add UI Lab to any Tailwind v4 project in under one minute.
Choose your path
Fastest: Start from a template. Browse pre-built Starters—Next.js, Vite, Astro, Tauri, and more. Clone, install, build. Everything's configured.
Quick: Use the CLI. One command sets up UI Lab in an existing project:
Manual: Full control. Follow the steps below for custom setups.
Interactive Installation
Step-by-step guidance for your framework:
Target framework
Installation Steps
1. Install core package
2. Define your app theme
3. Import styles in your app stylesheet
4. Load that stylesheet from your root entry
Verification
Start your dev server and render a test component:
Tailwind v4 does not need `tailwind.config.ts` for this setup. If the component renders with the expected tokens and spacing, the install is working.
Manual Installation
Prefer the manual path if you need a minimal setup or want to wire things in yourself.
Install the package
Important: Components are unstyled by default
UI Lab components provide semantic structure and accessibility but no visual styles out of the box. You must pair them with a theme package to render them visually.
The easiest way is to use ui-lab-theme-onyx, which provides:
- Complete color palette (8 colors × 9 shades each)
- Typography scale
- Spacing and radius tokens
- Light/dark mode support
Import styles in the right order
Add this to your app stylesheet (app/globals.css in Next.js, src/index.css or src/main.css in Vite).
The order matters:
tailwindcssestablishes the layers.ui-lab-theme-onyx/styles.cssdefines the design tokens (colors, typography, spacing).ui-lab-components/styles.cssconsumes those tokens to render components.
Using a custom theme instead
If you prefer to define your own token layer instead of using ui-lab-theme-onyx:
Your my-theme.css must define all required tokens:
--accent-{50,100,200,...,900},--background-*,--foreground-*,--success-*,--danger-*,--warning-*,--info-*--text-sm,--text-md,--text-lg,--text-xl--radius-sm,--radius-md,--radius-lg
See ui-lab-theme-onyx for the complete token structure.
Optional: wire up theme switching
If you want light/dark mode, keep the token definitions in your own theme.css and let prefers-color-scheme handle the unstamped system case.
For Next.js, the preferred setup is:
- Persist explicit
"light"or"dark"overrides in theui-lab-themecookie. - Read that cookie in the server
app/layout.tsx. - Apply
className,data-theme, andstyle.colorSchemeon<html>withparseThemeCookie()andresolveThemeRootState()fromui-lab-components/theme-server.
Leave system mode unstamped so CSS can handle first paint without an inline bootstrap script.
If you cannot use a cookie-backed server layout, ui-lab-components/theme-script is still available as a fallback. The full setup is documented in Theme Switching.
Render a component
If styles don't appear, verify that you've imported a theme package (e.g., ui-lab-theme-onyx/styles.css) before ui-lab-components/styles.css in your stylesheet.
Troubleshooting
Components have no visual styles
This is expected if you haven't installed a theme. UI Lab components are unstyled by default.
Install ui-lab-theme-onyx:
Then import it in your stylesheet before ui-lab-components/styles.css:
Styles look wrong or partially applied
Verify Tailwind v4:
Should show v4.x.x. If not: npm install tailwindcss@latest
PostCSS error
Check postcss.config.mjs includes:
Restart dev server after changes.
Styles still not applying
-
Check your stylesheet import order — theme package must come before
ui-lab-components: -
Verify a theme is installed — Run
npm ls ui-lab-theme-onyx(or check your custom theme package) -
Clear cache and restart:
rm -rf node_modules/.cache && npm run dev
Still stuck?
Compare against the Components gallery. File issues on GitHub.
Next steps
- Browse Components for the full library
- Explore Elements for composed UI patterns
- Check Starters for complete project templates