Installation

PrimeReact is a rich set of open source UI components for React.

PrimeReact is available for download at npm.


// with npm
npm install primereact

// with yarn
yarn add primereact
         

Configuration is managed by the PrimeReactProvider and PrimeReactContext imported from primereact/api.


import { PrimeReactProvider, PrimeReactContext } from 'primereact/api';
         

The PrimeReactProvider component is used to wrap the application and the PrimeReactContext is used to access the configuration options.


// _app.js
import { PrimeReactProvider } from 'primereact/api';

export default function MyApp({ Component, pageProps }) {
    return (
        <PrimeReactProvider>
            <Component {...pageProps} />
        </PrimeReactProvider>
    );
}
         

Each component can be imported individually so that you only bundle what you use. Import path is available in the documentation of the corresponding component.


import { Button } from 'primereact/button';                             
         

PrimeReact has two theming has modes; styled or unstyled.

Styled mode is based on pre-skinned components with opinionated themes like Material, Bootstrap or PrimeOne themes. Theme is the required css file to be imported, visit the Themes section for the complete list of available themes to choose from.


import "primereact/resources/themes/lara-light-cyan/theme.css";
 

Unstyled mode is disabled by default for all components. Using the PrimeReactContext during installation, set unstyled as true to enable it globally. Visit the Unstyled mode documentation for more information and examples.


import { PrimeReactProvider } from "primereact/api";
...
return(
    <PrimeReactProvider value={{ unstyled: true }}>
        <App />
    </PrimeReactProvider>
)
 

We've created various samples for the popular options in the React ecosystem.

Create React AppNext.JSCreate React AppViteRefine

Video tutorials to take you through step-by-step.

PrimeReact has first class support for SSR and Next.JS, in fact this website is also built with Next.js