PrimeUI PRO for React is now available 🚀View Demos

With React Router

Setting up PrimeReact Tailwind components in a React Router project.

Start from our React Router + 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:

npx shadcn@latest init -t react-router https://primereact.dev/r/theme.json

Wrap with PrimeReactProvider#

Wrap your app with PrimeReactProvider so component behavior and your PrimeUI license are available everywhere — see the PrimeReactProvider snippet below.

Add Components#

Add any component by its registry URL:

npx shadcn@latest add https://primereact.dev/r/button.json

Then pick your colors — see Theming.

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:

npm install primereact @primeicons/react tailwindcss-primeui tailwind-merge

Add the cn Helper#

The components rely on a cn utility to merge class names. Create lib/utils.ts and add the helper:

lib/utils.ts
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:

app/app.css
@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 app/root.tsx so component behavior and your PrimeUI license are available everywhere. Set darkModeSelector to the same .dark class used above:

app/root.tsx
import { Outlet } from 'react-router';
import { PrimeReactProvider } from '@primereact/core';
 
const primereact = {
    theme: {
        options: {
            darkModeSelector: '.dark'
        }
    },
    license: 'PrimeUI-Commercial-Key...'
};
 
export default function App() {
    return (
        <PrimeReactProvider {...primereact}>
            <Outlet />
        </PrimeReactProvider>
    );
}

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:

npx shadcn@latest add https://primereact.dev/r/button.json

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.