Start from our Vite + Tailwind template, pre-configured with PrimeReact.
Install via CLI#
PrimeReact's Tailwind components ship as a shadcn-compatible registry, so the shadcn CLI can scaffold everything for you. You need a project with Tailwind CSS v4 already set up.
Initialize#
Run init with the PrimeReact theme. This creates components.json, installs the base packages, adds the cn helper, and writes the design tokens (--p-primary-*, --p-surface-*) and the tailwindcss-primeui plugin to your global stylesheet:
Wrap with PrimeReactProvider#
Wrap your app with PrimeReactProvider so component behavior and your PrimeUI license are available everywhere — see the PrimeReactProvider snippet below.
Manual installation#
PrimeReact Tailwind components are distributed through a shadcn-compatible registry, each component is copied into your codebase, so there is no theme file or runtime theme provider to set up.
Install Packages#
Install PrimeReact along with the icon package and the Tailwind utilities the components rely on:
Add the cn Helper#
The components rely on a cn utility to merge class names. Create lib/utils.ts and add the helper:
import { cn as _cn } from '@primeuix/utils';
import { twMerge } from 'tailwind-merge';
export function cn(...inputs: unknown[]) {
return twMerge(_cn(...inputs));
}Set up Global Styles#
Import Tailwind and the tailwindcss-primeui plugin in your global stylesheet, and register the dark variant so utilities and components respond to a .dark class:
@import 'tailwindcss';
@import 'tailwindcss-primeui';
@custom-variant dark (&:where(.dark, .dark *));The PrimeReact design tokens (--p-primary-*, --p-surface-*, …) live under :root and .dark. Add them by running npx shadcn@latest add https://primereact.dev/r/theme.json, or copy them from the Theming guide.
PrimeReactProvider#
Wrap your app with PrimeReactProvider in src/main.tsx so component behavior and your PrimeUI license are available everywhere. Set darkModeSelector to the same .dark class used above:
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import App from './App.tsx';
import { PrimeReactProvider } from '@primereact/core';
import './index.css';
const primereact = {
theme: {
options: {
darkModeSelector: '.dark'
}
},
license: 'PrimeUI-Commercial-Key...'
};
createRoot(document.getElementById('root')!).render(
<StrictMode>
<PrimeReactProvider {...primereact}>
<App />
</PrimeReactProvider>
</StrictMode>
);Add Components#
You can add a component with the shadcn CLI, or add it manually. For example, to add the Button component with the CLI:
To add it manually instead, head to the Button component page and follow the install steps there.
Once added, import the component and render it to verify your setup:
import { Button } from '@/components/ui/button';
export default function VerifyInstallation() {
return (
<div className="card flex justify-center">
<Button>Verify</Button>
</div>
);
}Next Steps#
Theme your components with CSS variables, then browse the components to add and customize the ones you need.