Setting up PrimeNG in an Angular CLI project.
PrimeNG is available for download on the npm registry.
# Using npm
npm install primeng @primeng/themes
# Using yarn
yarn add primeng @primeng/themes
# Using pnpm
pnpm add primeng @primeng/themes
Add providePrimeNG and provideAnimationsAsync to the list of providers in your app.config.ts and use the theme property to configure a theme such as Aura.
import { ApplicationConfig } from '@angular/core';
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
import { providePrimeNG } from 'primeng/config';
import Aura from '@primeng/themes/aura';
export const appConfig: ApplicationConfig = {
providers: [
provideAnimationsAsync(),
providePrimeNG({
theme: {
preset: Aura
}
})
]
};
Verify your setup by adding a component such as Button. Each component can be imported and registered individually so that you only include what you use for bundle optimization. Import path is available in the documentation of the corresponding component.
import { ButtonModule } from 'primeng/button';
<div class="card flex justify-center">
<p-button label="Check"></p-button>
</div>
An example starter with Angular CLI is available at GitHub.
Welcome to the Prime UI Ecosystem! Once you have PrimeNG up and running, we recommend exploring the following resources to gain a deeper understanding of the library.