# PrimeReact
# Configuration
Application wide configuration for PrimeReact.
## Provider
Wrap your app with `PrimeReactProvider` in your main file (like `main.tsx` or `App.tsx`). This enables PrimeReact features everywhere in your app:
```tsx showLineNumbers {10, 12}
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import App from './App.tsx'
import { PrimeReactProvider } from "@primereact/core";
...
createRoot(document.getElementById('root')!).render(
,
)
```
## Theme
Style mode offers theming based on a design token based architecture. See the [styled mode](/docs/theming/styled) documentation for details such as building your own theme.
```tsx showLineNumbers {2,5-12,16}
...
import Aura from '@primeuix/themes/aura';
import { PrimeReactProvider } from '@primereact/core';
const theme = {
preset: Aura,
options: {
prefix: 'p',
darkModeSelector: 'system',
cssLayer: false
}
};
ReactDOM.createRoot(document.getElementById('root')).render(
);
```
## Unstyled
Unstyled mode instructs the components not to add any built-in style classes so that they can be styled using custom css or libraries like Tailwind and Bootstrap. Visit Unstyled mode documentation for more information.
```tsx showLineNumbers {6}
import { PrimeReactProvider } from '@primereact/core';
...
ReactDOM.createRoot(document.getElementById('root')).render(
);
```
## PassThrough
Defines the shared pass through properties per component type. Visit the [Pass Through Props](/docs/passthrough) documentation for more information.
```tsx showLineNumbers {4-8,12}
import { PrimeReactProvider } from '@primereact/core';
...
const pt = {
slider: {
handle: { className: 'bg-primary text-primary-contrast' }
}
};
ReactDOM.createRoot(document.getElementById('root')).render(
);
```
## PassThrough Options
Used to configure the `ptOptions` properties of components. The `mergeSections` defines whether the sections from the main configuration gets added and the `mergeProps` controls whether to override or merge the defined props.
Defaults are `true` for `mergeSections` and `false` for `mergeProps`.
```tsx showLineNumbers {4-7,11}
import { PrimeReactProvider } from '@primereact/core';
...
const ptOptions = {
mergeSections: true,
mergeProps: false
};
ReactDOM.createRoot(document.getElementById('root')).render(
);
```
## InputVariant
Input fields come in two styles, default is `outlined` with borders around the field whereas `filled` alternative adds a background color to the field.
Applying `p-variant-filled` to an ancestor of an input enables the filled style. If you prefer to use filled inputs in the entire application, use a global container such as the document body or the application element to apply the style class.
Note that in case you add it to the application element, components that are teleported to the document body such as Dialog will not be able to display filled inputs as they are not a descendant of the application root element in the DOM tree,
to resolve this case set inputVariant to `filled` at PrimeReactProvider as well.
```tsx showLineNumbers {6}
import { PrimeReactProvider } from '@primereact/core';
...
ReactDOM.createRoot(document.getElementById('root')).render(
);
```
# LLMs.txt
LLMs.txt is a file that contains the LLMs for the PrimeReact documentation.
## /llms.txt
The [llms.txt](https://llmstxt.org/) file is an industry standard that helps AI models better understand and navigate the PrimeReact documentation. It lists key pages in a structured format, making it easier for LLMs to retrieve relevant information.
## /llms-full.txt
The `llms-full.txt` file is a complete list of all the pages in the PrimeReact documentation. It is used to help AI models understand the entire documentation set.
## .md extension
Add a `.md` to a page’s URL to display a Markdown version of that page.
# Pass Through
The Pass Through attributes is an API to access the internal DOM Structure of the components.
## Introduction
In traditional 3rd party UI libraries, users are limited to the API provided by component author. This API commonly consists of props, events and slots. Whenever a requirement emerges for a new customization option in the API, the component
author needs to develop and publish it with a new release.
Vision of PrimeTek is _Your components, not ours_. The pass through feature is a key element to implement this vision by exposing the component internals in order to apply arbitrary attributes and listeners to the DOM elements. The primary
advantage of this approach is that it frees you from being restricted by the main component API. We recommend considering the pass-through feature whenever you need to tailor a component that lacks a built-in feature for your specific
requirement.
## Basic
Each component has a special `pt` property to define an object with keys corresponding to the available DOM elements. Each value can either be a string, an object or a function that returns a string or an object to define the
arbitrary properties to apply to the element such as styling, aria, data-\* or custom attributes. If the value is a string or a function that returns a string, it is considered as a className definition and added to the className attribute of the
element. Every component documentation has a dedicated section to document the available section names exposed via PT.
Most common usage of `pt` is styling and customization. Example below styles an unstyled Panel component with Tailwind CSS library.
```tsx
import { Panel } from 'primereact/panel';
export default function BasicDemo() {
return (
Header
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
);
}
```
## Global
Defines the shared pass through properties per component type. For example, with the configuration below all panel headers have the `bg-primary` style class and the all autocomplete components have a fixed width. These settings can be overriden by a particular component as components `pt` property has higher precedence over global `pt`.
```tsx
pt: {
panel: {
header: {
className: 'bg-primary text-primary-contrast'
}
},
autocomplete: {
input: {
root: 'w-64' // OR { class: 'w-64' }
}
}
}
```
## Custom CSS
The `global` property has a `css` option to define custom css that belongs to a global `pt` configuration. Common use case of this feature is defining global styles and animations related to the pass through configuration.
```tsx
pt: {
global: {
css: \`
.my-button {
border-width: 2px;
}
\`
},
button: {
root: 'my-button'
}
}
```
# Tailwind CSS
Integration between PrimeReact and Tailwind CSS both in styled and unstyled modes.
## Overview
Tailwind CSS is a popular CSS framework based on a utility-first design. The core provides flexible CSS classes with predefined CSS rules to build your own UI elements. For example, instead of an opinionated `btn` className as in
Bootstrap, Tailwind offers primitive classes like `bg-blue-500`, `rounded` and `p-4` to apply a button.
Tailwind is an outstanding CSS library, however it lacks a true comprehensive UI suite when combined with Vue.js, this is where PrimeReact comes in by providing a wide range of highly accessible and feature rich UI component library. The
core of PrimeReact does not depend on Tailwind CSS, instead we provide the necessary integration points such as the primeui tailwind plugin and the Tailwind version for the unstyled mode.
Tailwind CSS and PrimeReact can be used together via two main approaches. Simple approach is using Tailwind CSS _around_ PrimeReact components for layout purposes as demonstrated in the samples section below, the advanced approach takes the
integration a step further by allowing Tailwind CSS _within_ the component internals to style the entire UI suite in unstyled mode.
## Tailwind Theme
PrimeTek offers the Tailwind CSS version of the entire PrimeReact UI suite in unstyled mode based on the `@apply` directive with IntelliSense support. Visit the [Tailwind version of PrimeReact](https://tailwind.primereact.org) for the documentation, demos and additional resources.
Tailwind version of PrimeReact instead of the default styled mode is not tested with Tailwind v4. For the next-gen version of this project, we are building a new UI Component library based on the code ownership model where components are located
inside your project source instead of imported from npm. This new library is powered by Unstyled PrimeReact Core and Tailwind v4.
## Plugin
The [tailwindcss-primeui](https://www.npmjs.com/package/tailwindcss-primeui) is an official plugin by PrimeTek to provide first className integration between a Prime UI library like
PrimeReact and Tailwind CSS. It is designed to work both in styled and unstyled modes. In styled mode, for instance the semantic colors such as primary and surfaces are provided as Tailwind utilities e.g. `bg-primary`,
`text-surface-500`, `text-muted-color`.
If you haven't already done so, start by integrating Tailwind into your project. Detailed steps for this process can be found in the Tailwind [documentation](https://tailwindcss.com/).
After successfully installing Tailwind, proceed with the installation of the PrimeUI plugin. This single npm package comes with two libraries: the CSS version is compatible with Tailwind v4, while the JS version is designed for Tailwind
v3.
```bash
npm i tailwindcss-primeui
```
### Tailwind v4
In the CSS file that contains the tailwindcss import, add the `tailwindcss-primeui` import as well.
```css
@import 'tailwindcss';
@import 'tailwindcss-primeui';
```
### Tailwind v3
Use the plugins option in your Tailwind config file to configure the plugin.
```tsx
// tailwind.config.js
import PrimeUI from 'tailwindcss-primeui';
export default {
// ...
plugins: [PrimeUI]
};
```
## Extensions
The plugin extends the default configuration with a new set of utilities whose values are derived from the PrimeReact theme in use. All variants and breakpoints are supported e.g. `dark:sm:hover:bg-primary`.
| Class | Property |
| --------------------------- | ----------------------------------------- |
| `primary-[50-950]` | Primary color palette. |
| `surface-[0-950]` | Surface color palette. |
| `primary` | Default primary color. |
| `primary-contrast` | Default primary contrast color. |
| `primary-emphasis` | Default primary emphasis color. |
| `border-surface` | Default primary emphasis color. |
| `bg-emphasis` | Emphasis background e.g. hovered element. |
| `bg-highlight` | Highlight background. |
| `bg-highlight-emphasis` | Highlight background with emphasis. |
| `rounded-border` | Border radius. |
| `text-color` | Text color with emphasis. |
| `text-color-emphasis` | Default primary emphasis color. |
| `text-muted-color` | Secondary text color. |
| `text-muted-color-emphasis` | Secondary text color with emphasis. |
## Dark Mode
In styled mode, PrimeReact uses the `system` as the default `darkModeSelector` in theme configuration. If you have a dark mode switch in your application, ensure that `darkModeSelector` is aligned with the Tailwind dark
variant for seamless integration. Note that, this particular configuration isn't required if you're utilizing the default system color scheme.
Suppose that, the darkModeSelector is set as `my-app-dark` in PrimeReact.
```tsx showLineNumbers
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import App from './App.tsx';
import { PrimeReactProvider } from '@primereact/core';
import Aura from '@primeuix/themes/aura';
const primereact = {
theme: {
preset: Aura,
options: {
darkModeSelector: '.my-app-dark'
}
}
};
createRoot(document.getElementById('root')!).render(
);
```
### Tailwind v4
Add a custom variant for dark with a custom selector.
```css
@import "tailwindcss";
@import "tailwindcss-primeui";
@custom-variant dark (&:where(.my-app-dark, .my-app-dark *)); //dark mode configuration
```
### Tailwind v3
Use the plugins option in your Tailwind config file to configure the plugin.
```tsx
// tailwind.config.js
import PrimeUI from 'tailwindcss-primeui';
export default {
darkMode: ['selector', '[className~="my-app-dark"]'], //dark mode configuration
plugins: [PrimeUI]
};
```
## Override
Tailwind utilities may not be able to override the default styling of components due to css specificity, there are two possible solutions; Important and CSS Layer.
### Important
Use the `!` as a prefix to enforce the styling. This is not the recommend approach, and should be used as last resort to avoid adding unnecessary style classes to your bundle.
##### Tailwind v4
```tsx
```
##### Tailwind v3
```tsx
```
### CSS Layer
CSS Layer provides control over the css specificity so that Tailwind utilities can safely override components.
##### Tailwind v4
Ensure `primereact` layer is after `theme` and `base`, but before the other Tailwind layers such as `utilities`.
```tsx showLineNumbers
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import App from './App.tsx';
import { PrimeReactProvider } from '@primereact/core';
import Aura from '@primeuix/themes/aura';
const primereact = {
theme: {
preset: Aura,
options: {
cssLayer: {
name: 'primereact',
order: 'theme, base, primereact'
}
}
}
};
createRoot(document.getElementById('root')!).render(
);
```
No change in the CSS configuration is required.
```css
@import 'tailwindcss';
@import 'tailwindcss-primeui';
```
##### Tailwind v3
The `primereact` layer should be between base and utilities.
```tsx showLineNumbers
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import App from './App.tsx';
import { PrimeReactProvider } from '@primereact/core';
import Aura from '@primeuix/themes/aura';
const primereact = {
theme: {
preset: Aura,
options: {
cssLayer: {
name: 'primereact',
order: 'tailwind-base, primereact, tailwind-utilities'
}
}
}
};
createRoot(document.getElementById('root')!).render(
);
```
Tailwind v3 does not use native `layer` so needs to be defined with CSS.
```css
@layer tailwind-base, primereact, tailwind-utilities;
@layer tailwind-base {
@tailwind base;
}
@layer tailwind-utilities {
@tailwind components;
@tailwind utilities;
}
```
## Samples
Example uses cases with PrimeReact and Tailwind CSS.
### Color Palette
PrimeReact color palette as utility classes.
```tsx
export default function ColorPaletteDemo() {
const colors = ['primary', 'surface'];
const shades = [0, 50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
return (
{colors.map((color, i) => (
{color}
{shades.map((shade) => (
{shade}
))}
))}
primary
highlight
box
);
}
```
```tsx
primary
highlight
box
```
### Starter
The Tailwind v4 and PrimeReact [starter example](https://github.com/primefaces/primereact-examples/tree/main/vite-quickstart-nextgen) is available to demonstrate the integration setup with an example dashboard.
## Animations
The plugin also adds extended animation utilities that can be used with the styleclass and animateonscroll components.
### Animation Name
| Class | Property |
| ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `animate-enter` | animation-name: enter; --p-enter-opacity: initial; --p-enter-scale: initial; --p-enter-rotate: initial; --p-enter-translate-x: initial; --p-enter-translate-y: initial; |
| `animate-leave` | animation-name: leave; --p-leave-opacity: initial; --p-leave-scale: initial; --p-leave-rotate: initial; --p-leave-translate-x: initial; --p-leave-translate-y: initial; |
| `animate-leave` | fadein 0.15s linear |
| `animate-fadein` | fadein 0.15s linear |
| `animate-fadeout` | fadeout 0.15s linear |
| `animate-slidedown` | slidedown 0.45s ease-in-out |
| `animate-slideup` | slideup 0.45s cubic-bezier(0, 1, 0, 1) |
| `animate-scalein` | scalein 0.15s linear |
| `animate-fadeinleft` | fadeinleft 0.15s linear |
| `animate-fadeoutleft` | fadeoutleft 0.15s linear |
| `animate-fadeinright` | fadeinright 0.15s linear |
| `animate-fadeoutright` | fadeoutright 0.15s linear |
| `animate-fadeinup` | fadeinup 0.15s linear |
| `animate-fadeoutup` | fadeoutup 0.15s linear |
| `animate-fadeindown` | fadeindown 0.15s linear |
| `animate-fadeoutup` | fadeoutup 0.15s linear |
| `animate-width` | width 0.15s linear |
| `animate-flip` | flip 0.15s linear |
| `animate-flipup` | flipup 0.15s linear |
| `animate-flipleft` | fadein 0.15s linear |
| `animate-flipright` | flipright 0.15s linear |
| `animate-zoomin` | zoomin 0.15s linear |
| `animate-zoomindown` | zoomindown 0.15s linear |
| `animate-zoominleft` | zoominleft 0.15s linear |
| `animate-zoominright` | zoominright 0.15s linear |
| `animate-zoominup` | zoominup 0.15s linear |
### Animation Duration
| Class | Property |
| -------------------------- | -------------------------- |
| `animate-duration-0` | animation-duration: 0s |
| `animate-duration-75` | animation-duration: 75ms |
| `animate-duration-100` | animation-duration: 100ms |
| `animate-duration-200` | animation-duration: 200ms |
| `animate-duration-300` | animation-duration: 300ms |
| `animate-duration-400` | animation-duration: 400ms |
| `animate-duration-500` | animation-duration: 500ms |
| `animate-duration-700` | animation-duration: 700ms |
| `animate-duration-1000` | animation-duration: 1000ms |
| `animate-duration-2000` | animation-duration: 2000ms |
| `animate-duration-3000` | animation-duration: 300ms |
| `animate-duration-[value]` | animation-duration: value |
### Animation Delay
| Class | Property |
| -------------------- | ----------------------- |
| `animate-delay-none` | animation-duration: 0s |
| `animate-delay-75` | animation-delay: 75ms |
| `animate-delay-100` | animation-delay: 100ms |
| `animate-delay-150` | animation-delay: 150ms |
| `animate-delay-200` | animation-delay: 200ms |
| `animate-delay-300` | animation-delay: 300ms |
| `animate-delay-400` | animation-delay: 400ms |
| `animate-delay-500` | animation-delay: 500ms |
| `animate-delay-700` | animation-delay: 700ms |
| `animate-delay-1000` | animation-delay: 1000ms |
### Iteration Count
| Class | Property |
| ------------------ | ----------------------------------- |
| `animate-infinite` | animation-iteration-count: infinite |
| `animate-once` | animation-iteration-count: 1 |
| `animate-twice` | animation-iteration-count: 2 |
### Direction
| Class | Property |
| --------------------------- | -------------------------------------- |
| `animate-normal` | animation-direction: normal |
| `animate-reverse` | animation-direction: reverse |
| `animate-alternate` | animation-direction: alternate |
| `animate-alternate-reverse` | animation-direction: alternate-reverse |
### Timing Function
| Class | Property |
| --------------------- | ------------------------------------------------------- |
| `animate-ease-linear` | animation-timing-function: linear |
| `animate-ease-in` | animation-timing-function: cubic-bezier(0.4, 0, 1, 1) |
| `animate-ease-out` | animation-timing-function: cubic-bezier(0, 0, 0.2, 1) |
| `animate-ease-in-out` | animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1) |
### Fill Mode
| Class | Property |
| ------------------------ | ------------------------------ |
| `animate-fill-none` | animation-fill-mode: normal |
| `animate-fill-forwards` | animation-fill-mode: forwards |
| `animate-fill-backwards` | animation-fill-mode: backwards |
| `animate-fill-both` | animation-fill-mode: both |
### Play State
| Class | Property |
| ----------------- | ----------------------------- |
| `animate-running` | animation-play-state: running |
| `animate-paused` | animation-play-state: paused |
### Backface Visibility State
| Class | Property |
| ------------------ | ---------------------------- |
| `backface-visible` | backface-visibility: visible |
| `backface-hidden` | backface-visibility: hidden |
### Fade In and Out
Values are derived from the Tailwind CSS [opacity](https://tailwindcss.com/docs/opacity) e.g. _fade-in-50_ and _fade-out-20_. Arbitrary values such as _fade-in-[15]_ are also supported.
| Class | Property |
| ------------------ | ---------------------------- |
| `fade-in-{value}` | --p-enter-opacity: \{value\} |
| `fade-out-{value}` | --p-leave-opacity: \{value\} |
### Zoom In and Out
Values are derived from the Tailwind CSS [scale](https://tailwindcss.com/docs/scale) e.g. _zoom-in-50_ and _zoom-out-75_. Arbitrary values such as _zoom-in-[0.8]_ are also supported.
| Class | Property |
| ------------------ | -------------------------- |
| `zoom-in-{value}` | --p-enter-scale: \{value\} |
| `zoom-out-{value}` | --p-leave-scale: \{value\} |
### Spin In and Out
Values are derived from the Tailwind CSS [rotate](https://tailwindcss.com/docs/rotate) e.g. _spin-in-45_ and _spin-out-90_. Arbitrary values such as _spin-in-[60deg]_ are also supported.
| Class | Property |
| ------------------ | --------------------------- |
| `spin-in-{value}` | --p-enter-rotate: \{value\} |
| `spin-out-{value}` | --p-leave-rotate: \{value\} |
### Slide In and Out
Values are derived from the Tailwind CSS [translate](https://tailwindcss.com/docs/translate) e.g. _slide-in-from-t-50_ and _slide-out-to-l-8_. Arbitrary values such as _slide-in-from-b-[8px]_ are also supported.
| Class | Property |
| ------------------------- | --------------------------------- |
| `slide-in-from-t-{value}` | --p-enter-translate-y: -\{value\} |
| `slide-in-from-b-{value}` | --p-enter-translate-y: \{value\} |
| `slide-in-from-l-{value}` | --p-enter-translate-x: -\{value\} |
| `slide-in-from-r-{value}` | --p-enter-translate-x: \{value\} |
| `slide-out-to-t-{value}` | --p-leave-translate-y: -\{value\} |
| `slide-out-to-b-{value}` | --p-leave-translate-y: \{value\} |
| `slide-out-to-l-{value}` | --p-leave-translate-x: -\{value\} |
| `slide-out-to-r-{value}` | --p-leave-translate-x: \{value\} |
# Contribution Guide
Welcome to the PrimeReact Contribution Guide and thank you for considering contributing.
## Introduction
PrimeReact is a popular Vue UI library maintained by PrimeTek, a company renowned for its comprehensive set of UI components for various frameworks. PrimeTek is dedicated to providing high-quality, versatile, and accessible UI components
that help developers build better applications faster.
### Development Setup
To begin with, clone the PrimeReact repository from GitHub:
```bash
git clone https://github.com/primefaces/primereact.git
cd primereact
```
Then run the showcase in your local environment at `http://localhost:3000/`.
```bash
pnpm run setup
pnpm run dev
```
### Project Structure
PrimeReact utilizes a monorepo architecture, the libraries are located at `packages` folder and the website is at `apps/showcase`.
```bash
- apps
- showcase // website
- packages
- core // core api
- headless // headless components
- hooks // hooks for components
- icons // primeicons
- primereact // main package of components and directives
- styles // styles for components
- types // types for components
```
## Help Needed
PrimeReact is a community-driven project backed by the expertise and sponsorship of PrimeTek, and we appreciate any help you can provide. Here are some areas where you can contribute:
### Issue Triage
Help us manage issues by;
- Reproducing reported bugs
- Clarifying issue descriptions
- Tagging issues with appropriate labels
### Sending Pull Requests
We encourage you to send pull requests, especially for issues tagged with the `help-needed` label.
### Community Support
Assist other users by participating in the issue tracker, [GitHub discussions](https://github.com/orgs/primefaces/discussions/categories/primereact), and the [PrimeLand Discord](https://discord.gg/primefaces) server. Your expertise can help others solve problems and improve their experience with PrimeReact.
## Key Points
PrimeReact has several add-ons such as UI Kit, Premium Templates, and Blocks that rely on design tokens and styling. Any core structural changes, such as adding new props, events, or updating design tokens, should be communicated with the
core team to ensure consistency and compatibility.
## Communication
Join the Contributors channel on the [PrimeLand Discord](https://discord.gg/primefaces) server to connect with PrimeReact staff and fellow contributors. In this channel, you can discuss the areas you want to
contribute to and receive feedback. This channel is open to everyone who'd like to contribute.
## Pathway
PrimeTek offers an organization structure involving contributors and the core team:
### Contributor Role
After a certain period of frequent contributions, a community member is offered the Contributor role. On average, it may take about three months, but the exact duration can vary depending on the individual commitment.
### Committer Role
If a contributor actively participates in the codebase and PRs, their role may be upgraded to a Committer level, providing direct commit access to the PrimeReact codebase.
### Employment
PrimeTek prefers to hire team members from open source committers, so you may be offered a full-time position when a position becomes available.
## Benefits
Contributing to PrimeReact comes with several benefits. Being part of an open-source project will enhance your career and open up exciting opportunities. Contributors and Committers will be listed on our [team page](/docs/team). You'll gain significant visibility in the developer community while improving yourself as a professional.
You'll be invited to a private communication channel at Discord to get in touch with PrimeTek. In addition, contributors have access to all PrimeReact add-ons like Premium Templates, Blocks, and UI Kit free of charge.
## CLA
When a community member is offered the Contributor role, they are expected to sign a Contributor License Agreement (CLA) for legal purposes. This helps protect both the contributor and PrimeTek.
# Introduction
Next-generation UI Component suite for React.
## Overview
PrimeReact is a complete UI suite for React consisting of a rich set of UI components, icons, blocks, and application templates. The project's primary goal is to boost developer productivity by offering reusable solutions that are easy to tune and customize as an in-house library.
The project has been created by [PrimeTek](https://www.primetek.com.tr) a world-renowned vendor of popular UI Component suites, including [PrimeFaces](https://primefaces.org),
[PrimeNG](https://primeng.org), [PrimeReact](https://primereact.org), and [PrimeVue](https://primevue.org). All the members in [our team](/team) are full time employees of PrimeTek who share the same passion and vision for open
source to create awesome UI libraries. Depending on a 3rd party library may introduce risks if the library maintainers decide not to work on the project, however, this is not the case with PrimeReact as the track record of PrimeTek shows.
## Theming
PrimeReact can be styled in two modes; styled or unstyled. Styled mode is based on pre-skinned components with opinionated theme variants of PrimeOne design like Aura, Lara or Nora presets. Unstyled mode on the other hand, leaves the
styling to you while implementing the functionality and accessibility. Unstyled mode provides full control over the styling with no boundaries by implementing a pluggable architecture to utilize CSS libraries like Tailwind CSS, Bootstrap,
Bulma or your own custom CSS. This design is future proof as PrimeReact can be styled with any CSS library without actually depending on it in its core.
## Accessibility
PrimeReact has WCAG 2.1 AA level compliance; each component has a dedicated accessibility section to document several aspects, including keyboard and screen reader support. Through communication channels such as GitHub or Discord, numerous
accessibility experts worldwide continue to provide constant feedback to improve the accessibility features further. View the [accessibility guide](/guides/accessibility) to learn more.
## PassThrough
PassThrough is an innovative API to provide access to the internal DOM elements to add arbitrary attributes. In general, traditional UI component libraries encapsulate UI and logic with limited APIs that makes the developers dependant on
the library maintainer to extend this API by adding new props or events. With [Pass Through](/docs/passthrough) this limitation has been eliminated since, you'll be able to access the internal of the components to add
events and attributes. Some common use-cases are adding test attributes, additional aria attributes, custom events and styling.
## AddOns
PrimeReact does not require financial sponsorships from its community; instead, to be backed by a solid financial foundation, optional add-ons are offered. These include a Figma UI Kit, premium application templates, and reusable UI blocks
called PrimeBlocks. The add-ons are optional and there is no paywall when using PrimeReact.
# Setup
Installation guides for popular development environments.
## Guides
# Accessibility
PrimeReact has WCAG 2.1 AA level compliance, refer to the accessibility documentation of each component for detailed information.
## Introduction
According to the World Health Organization, 15% of the world population has a disability to some degree. As a result, accessibility features in any context such as a ramp for wheelchair users or a multimedia with captions are crucial to ensure content can be consumed by anyone.
Types of disabilities are diverse so you need to know your audience well and how they interact with the content created. There four main categories;
### Visual Impairments
Blindness, low-level vision or color blindness are the common types of visual impairments. Screen magnifiers and the color blind mode are usually built-in features of the browsers whereas for people who rely on screen readers, page developers are required to make sure content is readable by the readers. Popular readers are NVDA , JAWS and ChromeVox .
### Hearing Impairments
Deafness or hearing loss refers to the inability to hear sounds totally or partially. People with hearing impairments use assistive devices however it may not be enough when interacting with a web page. Common implementation is providing textual alternatives, transcripts and captions for content with audio.
### Mobility Impairments
People with mobility impairments have disabilities related to movement due to loss of a limb, paralysis or other varying reasons. Assistive technologies like a head pointer is a device to interact with a screen whereas keyboard or a trackpad remain as solutions for people who are not able to utilize a mouse.
### Cognitive Impairments
Cognitive impairments have a wider range that includes people with learning disabilities, depression and dyslexia. A well designed content also leads to better user experience for people without disabilities so designing for cognitive impairments result in better design for any user.
## WCAG
Correct page structure with the aid of assistive technologies are the core ingridients for an accessible web content. HTML is based on an accessible foundation, form controls can be used by keyboard by default and semantic HTML is easier to be processed by a screen reader.
[WCAG](https://www.w3.org/WAI/standards-guidelines/wcag/) refers to **Web Content Accessibility Guideline**, a standard managed by the WAI (Web Accessibility Initiative) of W3C (World Wide Web Consortium). WCAG consists of recommendations for making the web content more accessible. PrimeReact components aim high level of WCAG compliancy in the near future.
Various countries around the globe have governmental policies regarding web accessibility as well. Most well known of these are Section 508 in the US and [Web Accessibility Directive](https://digital-strategy.ec.europa.eu/en/policies/web-accessibility) of the European Union.
## Form Controls
Native form elements should be preferred instead of elements that are meant for other purposes like presentation. As an example, button below is rendered as a form control by the browser, can receive focus via tabbing and can be used with space key as well to trigger.
```tsx
```
On the other hand, a fancy css based button using a div has no keyboard or screen reader support.
```tsx
onButtonClick(event)}>
Click
```
`tabIndex` is required to make a div element accessible in addition to use a keydown to bring the keyboard support back. To avoid the overload and implementing functionality that is already provided by the browser, native form controls should be preferred.
```tsx
```
Form components must be related to another element that describes what the form element is used for. This is usually achieved with the `label` element.
```tsx
```
## Semantic HTML
HTML offers various element to organize content on a web page that screen readers are aware of. Preferring Semantic HTML for good semantics provide out of the box support for reader which is not possible when regular `div` elements with classes are used. Consider the following example that do not mean too much for readers.
```tsx
Header
```
Same layout can be achieved using the semantic elements with screen reader support built-in.
```tsx
Header
```
## WAI ARIA
ARIA refers to "Accessible Rich Internet Applications" is a suite to fill the gap where semantic HTML is inadequate. These cases are mainly related to rich UI components/widgets. Although browser support for rich UI components such as a datepicker or colorpicker has been improved over the past years many web developers still utilize UI components derived from standard HTML elements created by them or by other projects like PrimeReact. These types of components must provide keyboard and screen reader support, the latter case is where the WAI-ARIA is utilized.
ARIA consists of roles, properties and attributes. **Roles** define what the element is mainly used for e.g. `checkbox`, `dialog`, `tablist` whereas **States** and **Properties** define the metadata of the element like `aria-checked`, `aria-disabled`.
Consider the following case of a native checkbox. It has built-in keyboard and screen reader support.
```tsx
```
A fancy checkbox with css animations might look more appealing but accessibility might be lacking. Checkbox below may display a checked font icon with animations however it is not tabbable, cannot be checked with space key and cannot be read by a reader.
```tsx
{checked && }
```
One alternative is using ARIA roles for readers and use javascript for keyboard support. Notice the usage of `aria-labelledby` as a replacement of the `label` tag with `htmlFor`.
```tsx
Remember Me
onKeyDown(event)}>
{checked && }
```
However the best practice is combining semantic HTML for accessibility while keeping the design for UX. This approach involves hiding a native checkbox for accessibility and using javascript events to update its state. Notice the usage of `p-hidden-accessible` that hides the elements from the user but not from the screen reader.
```tsx
onKeyDown(event)} />
{checked && }
```
A working sample is the PrimeReact checkbox that is tabbable, keyboard accessible and is compliant with a screen reader. Instead of ARIA roles it relies on a hidden native checkbox.
```tsx
import { Checkbox } from 'primereact/checkbox';
export default function AccessibilityCheckboxDemo() {
return (
);
}
```
## Colors
Colors on a web page should aim a contrast ratio of at least 4.5:1 and consider a selection of colors that do not cause vibration.
### Good Contrast
Color contrast between the background and the foreground content should be sufficient enough to ensure readability. Example below displays two cases with good and bad samples.
GOOD
BAD
### Vibration
Color vibration is leads to an illusion of motion due to choosing colors that have low visibility against each other. Color combinations need to be picked with caution to avoid vibration.
VIBRATE
### Dark Mode
Highly saturated colors should be avoided when used within a dark design scheme as they cause eye strain. Instead desaturated colors should be preferred.
Indigo 500
Indigo 200
# RTL Support
Right-to-left direction support of PrimeReact.
## Configuration
The PrimeReact components natively support Right-to-Left (RTL) text direction through a modern CSS implementation utilizing FlexBox and classes like `*-inline-start` and `*-block-end`. Consequently, no JavaScript configuration is necessary; setting the document's text direction to RTL is sufficient to enable this feature.
The RTL setting can either be set using the `dir` attribute or with the `direction` style property.
### With Markup
```html
```
### With CSS
```css
html {
direction: rtl;
}
```
## Limitations
RTL is widely supported by the UI suite except the Galleria and Carousel components. These components will be enhanced with a modern implementation in upcoming versions with built-in support for RTL.
# Custom Icons
PrimeReact components can be used with any icon library using the templating features.
## Material
[Material icons](https://fonts.google.com/icons) is the official icon library based on Google Material Design.
```tsx
```
## FontAwesome
[Font Awesome](https://fontawesome.com/) is a popular icon library with a wide range of icons.
```tsx
```
## SVG
Inline SVGs are embedded inside the dom.
```tsx
```
## Image
Any type of image can be used as an icon.
```tsx
```
# Prime Icons
PrimeIcons is the default icon library of PrimeReact with over 250 open source icons developed by PrimeTek. PrimeIcons library is optional as PrimeReact components can use any icon with templating.
## Download
PrimeIcons is available at npm, run the following command to download it to your project.
```bash
npm install primeicons
```
## Import
CSS file of the icon library needs to be imported in `styles.css` of your application.
```css
@import 'primeicons/primeicons.css';
```
## Figma
PrimeIcons library is now available on [Figma Community](https://www.figma.com/community/file/1354343849355792252/primeicons). By adding them as a library, you can easily use these icons in your designs.
## Basic
PrimeIcons use the `pi pi-{icon}` syntax such as `pi pi-check`. A standalone icon can be displayed using an element such as `i` or `span`.
```tsx
```
## Size
Size of an icon is controlled with the font-size property of the element.
```tsx
```
## Color
Icon color is defined with the `color` property which is inherited from parent by default.
```tsx
```
## Spin
Special `pi-spin` className applies infinite rotation to an icon.
```tsx
```
## List
Here is the full list of PrimeIcons. More icons will be added periodically and you may also [request new icons](https://github.com/primefaces/primeicons/issues) at the issue tracker.
```tsx
import { IconService } from '@/services/icon.service';
import { InputText } from 'primereact/inputtext';
import * as React from 'react';
interface IconItem {
properties: {
id: string;
name: string;
};
icon: {
tags: string[];
};
}
export default function ListDemo() {
const [icons, setIcons] = React.useState(null);
const [filteredIcons, setFilteredIcons] = React.useState(null);
React.useEffect(() => {
IconService.getIcons().then((data) => {
const d_data = data;
const d_icons = d_data.filter((value: IconItem) => {
return value.icon.tags.indexOf('deprecate') === -1;
});
d_icons.sort((icon1: IconItem, icon2: IconItem) => {
if (icon1.properties.name < icon2.properties.name) return -1;
else if (icon1.properties.name > icon2.properties.name) return 1;
else return 0;
});
setIcons(d_icons);
setFilteredIcons(d_icons);
});
}, []);
const onFilter = (event: React.ChangeEvent) => {
if (!icons) {
setFilteredIcons([]);
}
if (!event.target.value) {
setFilteredIcons(icons);
}
if (event.target.value && icons) {
const sanitizedInput = event.target.value.replace(/[^\w\s]/gi, '').replace(/\s/g, '');
const newFilteredIcons = icons.filter((icon) => {
return (
icon.icon.tags.some((tag) =>
tag
.replace(/[^\w\s]/gi, '')
.replace(/\s/g, '')
.includes(sanitizedInput.toLowerCase())
) ||
icon.properties.name
.replace(/[^\w\s]/gi, '')
.replace(/\s/g, '')
.toLowerCase()
.includes(sanitizedInput.toLowerCase())
);
});
setFilteredIcons(newFilteredIcons);
}
};
return (
{filteredIcons?.map((icon) => (
pi-{icon.properties.name}
))}
);
}
```
# With Next.js
Setting up PrimeReact in a Next.js project.
## Working Example
Quickstart your project with our PrimeReact + Next.js template
Use this Next.js template pre-configured with PrimeReact to quickly start building your app with ready-to-use UI components and styles.
github.com/primefaces/primereact-examples
## Installation
### Install Packages
Install PrimeReact and a theme package using your favorite package manager:
```bash
npm install primereact@11.0.0-alpha.1 @primeuix/themes
```
### PrimeReactProvider
Create a `prime-ssr-provider.tsx` file in the root of your project and add the following code:
```tsx showLineNumbers
'use client';
import { PrimeReactProvider, PrimeReactStyleSheet } from '@primereact/core';
import { useServerInsertedHTML } from 'next/navigation';
import * as React from 'react';
import Aura from '@primeuix/themes/aura';
const styledStyleSheet = new PrimeReactStyleSheet();
export default function PrimeSSRProvider({
children
}: Readonly<{
children?: React.ReactNode;
}>) {
useServerInsertedHTML(() => {
const styleElements = styledStyleSheet.getAllElements();
styledStyleSheet.clear();
return <>{styleElements}>;
});
const primereact = {
theme: {
preset: Aura
}
};
return (
{children}
);
}
```
### Add SSRProvider
Import the `PrimeSSRProvider` in your root `layout.tsx` file and wrap your app with it.
```tsx showLineNumbers {2,12}
...
import PrimeSSRProvider from './prime-ssr-provider';
export default function RootLayout({
children
}: Readonly<{
children: React.ReactNode;
}>) {
return (
{children}
);
}
```
### Verify
To verify that PrimeReact is installed correctly, you can create a simple component such as Button and render it in your application.
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.
```tsx
import { Button } from 'primereact/button';
export default function VerifyDemo() {
return (
);
}
```
```tsx showLineNumbers {1,6}
import { Button } from 'primereact/button';
export default function VerifyInstallation() {
return (
);
}
```
## More Tips
- You can import and use only the components you need for a smaller bundle size.
- For icons, custom themes, and advanced setup, see the [PrimeReact documentation](https://v11.primereact.org/setup).
## Troubleshooting
If you encounter issues during installation or setup, check the following:
- Ensure that you have the latest version of Vite and Node.js installed.
- Verify that your project structure is correct and that the `PrimeReactProvider` is properly wrapped around your application.
- Check the browser console for any errors related to PrimeReact components or themes.
- If you are using TypeScript, ensure that you have the necessary type definitions installed.
- Refer to the [PrimeReact GitHub repository](https://github.com/primefaces/primereact) for more information and support.
# With Vite
Setting up PrimeReact in a Vite project.
## Working Example
Quickstart your project with our PrimeReact + Vite template
Use this Vite template pre-configured with PrimeReact to quickly start building your app with ready-to-use UI components and styles.
github.com/primefaces/primereact-examples
## Installation
### Install Packages
Install PrimeReact and a theme package using your favorite package manager:
```bash
npm install primereact@11.0.0-alpha.1 @primeuix/themes
```
### PrimeReactProvider
Wrap your app with `PrimeReactProvider` in your main file (like `main.tsx` or `App.tsx`). This enables PrimeReact features everywhere in your app:
```tsx showLineNumbers {5,11-13}
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import './index.css'
import App from './App.tsx'
import { PrimeReactProvider } from "@primereact/core";
...
createRoot(document.getElementById('root')!).render(
,
)
```
### Theme
PrimeReact supports many themes. To use the Aura theme, import it and pass it to the provider:
```tsx showLineNumbers {1,7-9,13}
import Aura from '@primeuix/themes/aura';
import { PrimeReactProvider } from '@primereact/core';
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';
const theme = {
preset: Aura
};
ReactDOM.createRoot(document.getElementById('root')).render(
);
```
### Verify
To verify that PrimeReact is installed correctly, you can create a simple component such as [Button](/button) and render it in your application.
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.
```tsx
import { Button } from 'primereact/button';
export default function VerifyDemo() {
return (
);
}
```
```tsx showLineNumbers {1,6}
import { Button } from 'primereact/button';
export default function VerifyInstallation() {
return (
);
}
```
## More Tips
- You can import and use only the components you need for a smaller bundle size.
- For icons, custom themes, and advanced setup, see the [PrimeReact documentation](https://v11.primereact.org/setup).
## Troubleshooting
If you encounter issues during installation or setup, check the following:
- Ensure that you have the latest version of Vite and Node.js installed.
- Verify that your project structure is correct and that the `PrimeReactProvider` is properly wrapped around your application.
- Check the browser console for any errors related to PrimeReact components or themes.
- If you are using TypeScript, ensure that you have the necessary type definitions installed.
- Refer to the [PrimeReact GitHub repository](https://github.com/primefaces/primereact) for more information and support.
# Styled Mode
Choose from a variety of pre-styled themes or develop your own.
## Architecture
PrimeReact is a design agnostic library so unlike some other UI libraries it does not enforce a certain styling such as material design. Styling is decoupled from the components using the themes instead. A theme consists of two parts; _base_ and _preset_. The base is the style rules with CSS variables as placeholders whereas the preset is a set of design tokens to feed a base by mapping the tokens to CSS variables. A base may be configured with different presets,
currently Aura, Material, Lara and Nora are the available built-in options.

The core of the styled mode architecture is based on a concept named _design token_, a preset defines the token configuration in 3 tiers; _primitive_, _semantic_ and _component_.
### Primitive Tokens
Primitive tokens have no context, a color palette is a good example for a primitive token such as `blue-50` to `blue-900`. A token named `blue-500` may be used as the primary color, the background of a message however on its own, the name of the token does not indicate context. Usually they are utilized by the semantic tokens.
### Semantic Tokens
Semantic tokens define content and their names indicate where they are utilized, a well known example of a semantic token is the `primary.color`. Semantic tokens map to primitive tokens or other semantic tokens. The `colorScheme` token group is a special variable to define tokens based on the color scheme active in the application, this allows defining different tokens based on the color scheme like dark mode.
### Component Tokens
Component tokens are isolated tokens per component such as `inputtext.background` or `button.color` that map to the semantic tokens. As an example, `button.background` component token maps to the `primary.color` semantic token which maps to the `green.500` primitive token.
### Best Practices
Use primitive tokens when defining the core color palette and semantic tokens to specify the common design elements such as focus ring, primary colors and surfaces. Components tokens should only be used when customizing a specific
component. By defining your own design tokens as a custom preset, you'll be able to define your own style without touching CSS. Overriding the PrimeReact components using style classes is not a best practice and should be the last resort,
design tokens are the suggested approach.
## Configuration API
### Theme
The `theme` property is used to customize the initial theme.
### Options
The `options` property defines the how the CSS would be generated from the design tokens of the preset.
#### prefix
The prefix of the CSS variables, defaults to `p`. For instance, the `primary.color` design token would be `var(--p-primary-color)`.
```tsx
options: {
prefix: 'my';
}
```
#### darkModeSelector
The CSS rule to encapsulate the CSS variables of the dark mode, the default is the `system` to generate `@media (prefers-color-scheme: dark)`. If you need to make the dark mode toggleable based on the user selection define a
class selector such as `.app-dark` and toggle this class at the document root. See the dark mode toggle section for an example.
```tsx
options: {
darkModeSelector: '.my-app-dark';
}
```
#### cssLayer
Defines whether the styles should be defined inside a [CSS layer](https://developer.mozilla.org/en-US/docs/Web/CSS/@layer) by default or not. A CSS layer would be handy to declare a
custom cascade layer for easier customization if necessary. The default is `false`.
```tsx
options: {
cssLayer: {
name: 'primereact',
order: 'app-styles, primereact, another-css-library'
}
}
```
### Presets
Aura, Material, Lara and Nora are the available built-in options, created to demonstrate the power of the design-agnostic theming. Aura is PrimeTek's own vision, Material follows Google Material Design v2, Lara is based on Bootstrap and
Nora is inspired by enterprise applications. Visit the [source code](https://github.com/primefaces/primeuix/tree/main/packages/themes/src/presets)
to learn more about the structure of presets. You may use them out of the box with modifications or utilize them as reference in case you need to build your own presets from scratch.
### Reserved Keys
Following keys are reserved in the preset scheme and cannot be used as a token name; `primitive`, `semantic`, `components`, `directives`, `colorscheme`, `light`, `dark`, `common`, `root`, `states`, and `extend`.
### Colors
Color palette of a preset is defined by the `primitive` design token group. You can access colors using CSS variables or the `$dt` utility.
```tsx
// With CSS
var(--p-blue-500)
// With JS
$dt('blue.500').value
```
```tsx
export default function ColorsListDemo() {
const colors = ['emerald', 'green', 'lime', 'red', 'orange', 'amber', 'yellow', 'teal', 'cyan', 'sky', 'blue', 'indigo', 'violet', 'purple', 'fuchsia', 'pink', 'rose', 'slate', 'gray', 'zinc', 'neutral', 'stone'];
const shades = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
return (
{colors.map((color, i) => (
{color}
{shades.map((shade, j) => (
{shade}
))}
))}
);
}
```
## Dark Mode
PrimeReact uses the `system` as the default `darkModeSelector` in theme configuration. If you have a dark mode switch in your application, set the `darkModeSelector` to the selector you utilize such as `.my-app-dark` so that PrimeReact can fit in
seamlessly with your color scheme.
```tsx
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import App from './App.tsx';
import { PrimeReactProvider } from '@primereact/core';
import Aura from '@primeuix/themes/aura';
const primereact = {
theme: {
preset: Aura,
options: {
darkModeSelector: '.my-app-dark'
}
}
};
createRoot(document.getElementById('root')!).render(
);
```
Following is a very basic example implementation of a dark mode switch, you may extend it further by involving `prefers-color-scheme` to retrieve it from the system initially and use `localStorage` to make it stateful. See this [article](https://dev.to/abbeyperini/dark-mode-toggle-and-prefers-color-scheme-4f3m) for more information.
```tsx
```
```tsx
const toggleDarkMode = () => {
document.documentElement.classList.toggle('my-app-dark');
};
```
In case you prefer to use dark mode all the time, apply the `darkModeSelector` initially and never change it.
```tsx
```
It is also possible to disable dark mode completely using `false` or `none` as the value of the selector.
```tsx
theme: {
preset: Aura,
options: {
darkModeSelector: false || 'none',
}
}
```
## Customization
### definePreset
The `definePreset` utility is used to customize an existing preset during the PrimeReact setup. The first parameter is the preset to customize and the second is the design tokens to override.
```tsx
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import App from './App.tsx';
import { PrimeReactProvider } from '@primereact/core';
import { definePreset } from '@primeuix/themes';
import Aura from '@primeuix/themes/aura';
const MyPreset = definePreset(Aura, {
//Your customizations, see the following sections for examples
});
const primereact = {
theme: {
preset: MyPreset
}
};
createRoot(document.getElementById('root')!).render(
);
```
### Primary
The `primary` defines the main color palette, default value maps to the `emerald` primitive token. Let's setup to use `indigo` instead.
```tsx
const MyPreset = definePreset(Aura, {
semantic: {
primary: {
50: '{indigo.50}',
100: '{indigo.100}',
200: '{indigo.200}',
300: '{indigo.300}',
400: '{indigo.400}',
500: '{indigo.500}',
600: '{indigo.600}',
700: '{indigo.700}',
800: '{indigo.800}',
900: '{indigo.900}',
950: '{indigo.950}'
}
}
});
```
### Surface
The color scheme palette that varies between light and dark modes is specified with the surface tokens. Example below uses `zinc` for light mode and `slategray` for dark mode. With this setting, light mode, would have a
grayscale tone and dark mode would include bluish tone.
```tsx
const MyPreset = definePreset(Aura, {
semantic: {
colorScheme: {
light: {
surface: {
0: '#ffffff',
50: '{zinc.50}',
100: '{zinc.100}',
200: '{zinc.200}',
300: '{zinc.300}',
400: '{zinc.400}',
500: '{zinc.500}',
600: '{zinc.600}',
700: '{zinc.700}',
800: '{zinc.800}',
900: '{zinc.900}',
950: '{zinc.950}'
}
},
dark: {
surface: {
0: '#ffffff',
50: '{slate.50}',
100: '{slate.100}',
200: '{slate.200}',
300: '{slate.300}',
400: '{slate.400}',
500: '{slate.500}',
600: '{slate.600}',
700: '{slate.700}',
800: '{slate.800}',
900: '{slate.900}',
950: '{slate.950}'
}
}
}
}
});
```
### Noir
The `noir` mode is the nickname of a variant that uses surface tones as the primary and requires and additional `colorScheme` configuration to implement. A sample preset configuration with black and white variants as the primary
color;
```tsx
const Noir = definePreset(Aura, {
semantic: {
primary: {
50: '{zinc.50}',
100: '{zinc.100}',
200: '{zinc.200}',
300: '{zinc.300}',
400: '{zinc.400}',
500: '{zinc.500}',
600: '{zinc.600}',
700: '{zinc.700}',
800: '{zinc.800}',
900: '{zinc.900}',
950: '{zinc.950}'
},
colorScheme: {
light: {
primary: {
color: '{zinc.950}',
inverseColor: '#ffffff',
hoverColor: '{zinc.900}',
activeColor: '{zinc.800}'
},
highlight: {
background: '{zinc.950}',
focusBackground: '{zinc.700}',
color: '#ffffff',
focusColor: '#ffffff'
}
},
dark: {
primary: {
color: '{zinc.50}',
inverseColor: '{zinc.950}',
hoverColor: '{zinc.100}',
activeColor: '{zinc.200}'
},
highlight: {
background: 'rgba(250, 250, 250, .16)',
focusBackground: 'rgba(250, 250, 250, .24)',
color: 'rgba(255,255,255,.87)',
focusColor: 'rgba(255,255,255,.87)'
}
}
}
}
});
```
### Font
There is no design for fonts as UI components inherit their font settings from the application.
### Forms
The design tokens of the form input components are derived from the `form.field` token group. This customization example changes border color to primary on hover. Any component that depends on this semantic token such as
`dropdown.hover.border.color` and `textarea.hover.border.color` would receive the change.
```tsx
const MyPreset = definePreset(Aura, {
semantic: {
colorScheme: {
light: {
formField: {
hoverBorderColor: '{primary.color}'
}
},
dark: {
formField: {
hoverBorderColor: '{primary.color}'
}
}
}
}
});
```
### Focus Ring
Focus ring defines the outline width, style, color and offset. Let's use a thicker ring with the primary color for the outline.
```tsx
const MyPreset = definePreset(Aura, {
semantic: {
focusRing: {
width: '2px',
style: 'dashed',
color: '{primary.color}',
offset: '1px'
}
}
});
```
### Component
The design tokens of a specific component is defined at `components` layer. Overriding components tokens is not the recommended approach if you are building your own style, building your own preset should be preferred instead. This
configuration is global and applies to all card components, in case you need to customize a particular component on a page locally, view the Scoped CSS section for an example.
```tsx
const MyPreset = definePreset(Aura, {
components: {
card: {
colorScheme: {
light: {
root: {
background: '{surface.0}',
color: '{surface.700}'
},
subtitle: {
color: '{surface.500}'
}
},
dark: {
root: {
background: '{surface.900}',
color: '{surface.0}'
},
subtitle: {
color: '{surface.400}'
}
}
}
}
}
});
```
### Extend
The theming system can be extended by adding custom design tokens and additional styles. This feature provides a high degree of customization, allowing you to adjust styles according to your needs, as you are not limited to the default tokens.
The example preset configuration adds a new `accent` button with custom `button.accent.color` and `button.accent.inverse.color` tokens. It is also possible to add tokens globally to share them within the components.
```tsx
const MyPreset = definePreset(Aura, {
components: {
// custom button tokens and additional style
button: {
extend: {
accent: {
color: '#f59e0b',
inverseColor: '#ffffff'
}
}
css: ({ dt }) => \`
.p-button-accent {
background: \${dt('button.accent.color')};
color: \${dt('button.accent.inverse.color')};
transition-duration: \${dt('my.transition.fast')};
}
\`
}
},
// common tokens and styles
extend: {
my: {
transition: {
slow: '0.75s'
normal: '0.5s'
fast: '0.25s'
},
imageDisplay: 'block'
}
},
css: ({ dt }) => \`
/* Global CSS */
img {
display: \${dt('my.image.display')};
}
\`
});
```
## Scoped Tokens
Design tokens can be scoped to a certain component using the `dt` property. In this example, first switch uses the global tokens whereas second one overrides the global with its own tokens.
```tsx
import { Switch } from 'primereact/switch';
export default function ScopedTokensDemo() {
const amberSwitch = {
handle: {
borderRadius: '4px'
},
colorScheme: {
light: {
root: {
checkedBackground: '{amber.500}',
checkedHoverBackground: '{amber.600}',
borderRadius: '4px'
},
handle: {
checkedBackground: '{amber.50}',
checkedHoverBackground: '{amber.100}'
}
},
dark: {
root: {
checkedBackground: '{amber.400}',
checkedHoverBackground: '{amber.300}',
borderRadius: '4px'
},
handle: {
checkedBackground: '{amber.900}',
checkedHoverBackground: '{amber.800}'
}
}
}
};
return (
);
}
```
## Utils
### usePreset
Replaces the current presets entirely, common use case is changing the preset dynamically at runtime.
```tsx
import { usePreset } from '@primeuix/themes';
const onButtonClick() {
usePreset(MyPreset);
}
```
### updatePreset
Merges the provided tokens to the current preset, an example would be changing the primary color palette dynamically.
```tsx
import { updatePreset } from '@primeuix/themes';
const changePrimaryColor() {
updatePreset({
semantic: {
primary: {
50: '{indigo.50}',
100: '{indigo.100}',
200: '{indigo.200}',
300: '{indigo.300}',
400: '{indigo.400}',
500: '{indigo.500}',
600: '{indigo.600}',
700: '{indigo.700}',
800: '{indigo.800}',
900: '{indigo.900}',
950: '{indigo.950}'
}
}
})
}
```
### updatePrimaryPalette
Updates the primary colors, this is a shorthand to do the same update using `updatePreset`.
```tsx
import { updatePrimaryPalette } from '@primeuix/themes';
const changePrimaryColor() {
updatePrimaryPalette({
50: '{indigo.50}',
100: '{indigo.100}',
200: '{indigo.200}',
300: '{indigo.300}',
400: '{indigo.400}',
500: '{indigo.500}',
600: '{indigo.600}',
700: '{indigo.700}',
800: '{indigo.800}',
900: '{indigo.900}',
950: '{indigo.950}'
});
}
```
### updateSurfacePalette
Updates the surface colors, this is a shorthand to do the same update using `updatePreset`.
```tsx
import { updateSurfacePalette } from '@primeuix/themes';
const changeSurfaces() {
//changes surfaces both in light and dark mode
updateSurfacePalette({
50: '{zinc.50}',
// ...
950: '{zinc.950}'
});
}
const changeLightSurfaces() {
//changes surfaces only in light
updateSurfacePalette({
light: {
50: '{zinc.50}',
// ...
950: '{zinc.950}'
}
});
}
const changeDarkSurfaces() {
//changes surfaces only in dark mode
updateSurfacePalette({
dark: {
50: '{zinc.50}',
// ...
950: '{zinc.950}'
}
});
}
```
### $dt
The `$dt` function returns the information about a token like the full path and value. This would be useful if you need to access tokens programmatically.
```tsx
import { $dt } from '@primeuix/themes';
const duration = $dt('transition.duration');
/*
duration: {
name: '--transition-duration',
variable: 'var(--p-transition-duration)',
value: '0.2s'
}
*/
const primaryColor = $dt('primary.color');
/*
primaryColor: {
name: '--primary-color',
variable: 'var(--p-primary-color)',
value: {
light: {
value: '#10b981',
paths: {
name: 'semantic.primary.color',
binding: {
name: 'primitive.emerald.500'
}
}
},
dark: {
value: '#34d399',
paths: {
name: 'semantic.primary.color',
binding: {
name: 'primitive.emerald.400'
}
}
}
}
}
*/
```
### palette
Returns shades and tints of a given color from 50 to 950 as an object.
```tsx
import { palette } from '@primeuix/themes';
// custom color
const values1 = palette('#10b981');
// copy an existing token set
const primaryColor = palette('{blue}');
```
## CSS Layer
The PrimeReact CSS layer only applies to styled mode when layering is enabled explicitly at theme configuration, in unstyled mode the built-in CSS classes are not included and as a result no layer is necessary.
### Specificity
The `@layer` is a standard CSS feature to define cascade layers for a customizable order of precedence. If you need to become more familiar with layers, visit the documentation at [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/@layer) to begin with.
The `cssLayer` is disabled by default, when it is enabled at theme configuration, PrimeReact wraps the built-in style classes under the `primereact` cascade layer to make the library styles easy to override. CSS in your app without a layer has the
highest CSS specificity, so you'll be able to override styles regardless of the location or how strong a class is written.
Layers also make it easier to use CSS Modules, view the CSS Modules guide for examples.
### Reset
In case PrimeReact components have visual issues in your application, a Reset CSS may be the culprit. CSS layers would be an efficient solution that involves enabling the PrimeReact layer, wrapping the Reset CSS in another layer and defining the
layer order. This way, your Reset CSS does not get in the way of PrimeReact components.
```css
/* Order */
@layer reset, primereact;
/* Reset CSS */
@layer reset {
button,
input {
/* CSS to Reset */
}
}
```
## CSS Modules
[CSS modules](https://github.com/css-modules/css-modules) are supported by enabling the `module` property on a style element within your SFC. Use the `$style` keyword to apply classes to a PrimeReact component. It is recommend to enable
`cssLayer` when using CSS modules so that the PrimeReact styles have low CSS specificity.
```tsx
import * as React from 'react';
import { InputText } from 'primereact/inputtext';
import styles from './css-modules-demo.module.css';
export default function CSSModulesDemo() {
return (
);
}
```
```css
.myinput {
border-radius: 2rem;
padding: 1rem 2rem;
border-width: 2px;
}
```
## Scale
PrimeReact UI component use `rem` units, 1rem equals to the font size of the `html` element which is `16px` by default. Use the root font-size to adjust the size of the components globally. This website uses `14px` as the base
so it may differ from your application if your base font size is different.
```css
html {
font-size: 14px;
}
```
# Unstyled Mode
Build fully customizable components with complete control over styling by disabling default themes and implementing your own design system.
## Architecture
The term `unstyled` is used to define an alternative styling approach instead of the default theming with design tokens. In unstyled mode the css variables of the design tokens and the css rule sets that utilize them are not
included. Here is an example of an Unstyled Checkbox, the core functionality and accessibility is provided whereas styling is not included. Unstyled components still need to be styled on your end, in the next sections, we'll cover the
styling solutions for both modes.
```tsx
import { Checkbox } from 'primereact/checkbox';
export default function CheckboxDemo() {
return (
);
}
```
## Setup
Unstyled mode is enabled for the whole suite by enabling `unstyled` option during PrimeReact installation.
```tsx showLineNumbers
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import App from './App.tsx';
import { PrimeReactProvider } from '@primereact/core';
createRoot(document.getElementById('root')!).render(
);
```
Alternatively even in the default styled mode, a particular component can still be used as unstyled by adding the `unstyled` prop of the component.
```tsx
import { Button } from 'primereact/button';
export default function AlternativeButtonDemo() {
return (
);
}
```
## Example
Here is a sample that styles a button component with Tailwind CSS using [passthrough](/docs/passthrough) attributes. Before beginning, head over to the the pass through section at
[button](/docs/button) documentation to learn more about the components internals section. We'll be using the `root` element to add a custom style.
```tsx
import { Button } from 'primereact/button';
export default function ButtonDemo() {
return (
);
}
```
## Global
A global configuration can be created at application level to avoid repetition via the global `pt` option so that the styles can be shared from a single location. A particular component can still override a global configuration with
its own `pt` property.
```tsx showLineNumbers
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import App from './App.tsx';
import { PrimeReactProvider } from '@primereact/core';
const globalPT = {
button: {
root: "bg-teal-500 hover:bg-teal-700 active:bg-teal-900 cursor-pointer py-2 px-4 rounded-full border-0 flex gap-2 text-white text-lg font-bold"
}
panel: {
header: 'bg-primary text-primary-contrast border-primary',
content: 'border-primary text-lg text-primary-700',
title: 'bg-primary text-primary-contrast text-xl'
}
};
createRoot(document.getElementById('root')!).render(
);
```
# Accordion API
API documentation for Accordion component
## Accordion
### Props
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| ref | Ref | null | The reference to the component instance. |
| pIf | boolean | true | Whether the component should be rendered. |
| style | CSSProperties \\| ((instance?: AccordionInstance) => CSSProperties) | null | The style to apply to the component. |
| className | string \\| ((instance?: AccordionInstance) => string) | null | The class name to apply to the component. |
| as | string \\| number \\| bigint \\| boolean \\| ComponentClass \\| FunctionComponent \\| ReactElement> \\| Iterable \\| ReactPortal \\| Promise | null | The component type to render. |
| asChild | boolean | false | Whether the component should be rendered as a child component. |
| pt | SafeRecord | null | The pass-through props to pass to the component |
| ptOptions | PassThroughOptions | null | The pass-through options to pass to the component |
| unstyled | boolean | null | Whether the component should be rendered without classes. |
| dt | unknown | null | The design token to use for the component. |
| styles | StylesOptions | null | The styles to use for the component. |
| children | ReactNode \\| ((instance: AccordionInstance) => ReactNode) | null | The children to render. |
| lazy | boolean | false | When enabled, hidden tabs are not rendered at all. Defaults to false that hides tabs with css. |
| tabIndex | number | 0 | Index of the element in tabbing order. |
| defaultValue | string \\| number \\| (string \\| number)[] | null | Default value of the active panel or an array of values in multiple mode. |
| value | string \\| number \\| (string \\| number)[] | null | Value of the active panel or an array of values in multiple mode. |
| multiple | boolean | false | When enabled, multiple tabs can be activated at the same time. |
| selectOnFocus | boolean | false | When enabled, the accordion will be selected on focus. |
| onValueChange | (event: useAccordionChangeEvent) => void | null | Callback fired when the accordion's value changes. |
| [key: string] | any | null | |
| pt-{optionName}-* | - | null | Pass through attributes for customizing component. For more info, see Pass Through tab. |
### State
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| value | string \\| number \\| (string \\| number)[] | null | Value of the active panel or an array of values in multiple mode. |
### Exposes
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| state | useAccordionState | null | The state of the useAccordion. |
| updateValue | (key: string \\| number) => void | null | The method to update the value of the active panel. |
| isItemActive | (key: string \\| number) => boolean | null | The method to check if the panel is active. |
| onHeaderClick | (event: MouseEvent, value: string \\| number) => void | null | The method to handle the click event of the accordion header. |
| onHeaderFocus | (event: FocusEvent, value: string \\| number) => void | null | The method to handle the focus event of the accordion header. |
| onHeaderKeyDown | (event: KeyboardEvent, value: string \\| number) => void | null | The method to handle the key down event of the accordion header. |
### Interfaces
| Label | Description | Data |
|:------|:------|:------|
| PassThroughOptions | Defines passthrough(pt) options of Accordion component. | [object Object],[object Object],[object Object],[object Object],[object Object] |
### Types
| Label | Description | Data |
|:------|:------|:------|
| Instance | Instance of Avatar component. | [object Object] |
## AccordionPanel
### Props
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| ref | Ref | null | The reference to the component instance. |
| pIf | boolean | true | Whether the component should be rendered. |
| style | CSSProperties \\| ((instance?: AccordionPanelInstance) => CSSProperties) | null | The style to apply to the component. |
| className | string \\| ((instance?: AccordionPanelInstance) => string) | null | The class name to apply to the component. |
| as | string \\| number \\| bigint \\| boolean \\| ComponentClass \\| FunctionComponent \\| ReactElement> \\| Iterable \\| ReactPortal \\| Promise | null | The component type to render. |
| asChild | boolean | false | Whether the component should be rendered as a child component. |
| pt | SafeRecord | null | The pass-through props to pass to the component |
| ptOptions | PassThroughOptions | null | The pass-through options to pass to the component |
| unstyled | boolean | null | Whether the component should be rendered without classes. |
| dt | unknown | null | The design token to use for the component. |
| styles | StylesOptions | null | The styles to use for the component. |
| children | ReactNode \\| ((instance: AccordionPanelInstance) => ReactNode) | null | The children to render. |
| value | string \\| number | null | Unique value of item. |
| disabled | boolean | false | Whether the item is disabled. |
| [key: string] | any | null | |
| pt-{optionName}-* | - | null | Pass through attributes for customizing component. For more info, see Pass Through tab. |
### Exposes
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| accordion | AccordionInstance | null | The Accordion component instance. |
| active | boolean | null | Whether the item is active. |
### Interfaces
| Label | Description | Data |
|:------|:------|:------|
| PassThroughOptions | Defines passthrough(pt) options of AccordionPanel component. | [object Object] |
### Types
| Label | Description | Data |
|:------|:------|:------|
| Instance | Instance of AccordionPanel component. | [object Object] |
## AccordionHeader
### Props
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| ref | Ref | null | The reference to the component instance. |
| pIf | boolean | true | Whether the component should be rendered. |
| style | CSSProperties \\| ((instance?: AccordionHeaderInstance) => CSSProperties) | null | The style to apply to the component. |
| className | string \\| ((instance?: AccordionHeaderInstance) => string) | null | The class name to apply to the component. |
| as | string \\| number \\| bigint \\| boolean \\| ComponentClass \\| FunctionComponent \\| ReactElement> \\| Iterable \\| ReactPortal \\| Promise | null | The component type to render. |
| asChild | boolean | false | Whether the component should be rendered as a child component. |
| pt | SafeRecord | null | The pass-through props to pass to the component |
| ptOptions | PassThroughOptions | null | The pass-through options to pass to the component |
| unstyled | boolean | null | Whether the component should be rendered without classes. |
| dt | unknown | null | The design token to use for the component. |
| styles | StylesOptions | null | The styles to use for the component. |
| children | ReactNode \\| ((instance: AccordionHeaderInstance) => ReactNode) | null | The children to render. |
| [key: string] | any | null | |
| pt-{optionName}-* | - | null | Pass through attributes for customizing component. For more info, see Pass Through tab. |
### Exposes
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| accordion | AccordionInstance | null | The Accordion component instance. |
| accordionpanel | AccordionPanelInstance | null | The AccordionPanel component instance. |
### Interfaces
| Label | Description | Data |
|:------|:------|:------|
| PassThroughOptions | Defines passthrough(pt) options of AccordionHeader component. | [object Object] |
### Types
| Label | Description | Data |
|:------|:------|:------|
| Instance | Instance of AccordionHeader component. | [object Object] |
## AccordionHeaderIndicator
### Props
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| ref | Ref | null | The reference to the component instance. |
| pIf | boolean | true | Whether the component should be rendered. |
| style | CSSProperties \\| ((instance?: AccordionHeaderIndicatorInstance) => CSSProperties) | null | The style to apply to the component. |
| className | string \\| ((instance?: AccordionHeaderIndicatorInstance) => string) | null | The class name to apply to the component. |
| as | string \\| number \\| bigint \\| boolean \\| ComponentClass \\| FunctionComponent \\| ReactElement> \\| Iterable \\| ReactPortal \\| Promise | null | The component type to render. |
| asChild | boolean | false | Whether the component should be rendered as a child component. |
| pt | SafeRecord | null | The pass-through props to pass to the component |
| ptOptions | PassThroughOptions | null | The pass-through options to pass to the component |
| unstyled | boolean | null | Whether the component should be rendered without classes. |
| dt | unknown | null | The design token to use for the component. |
| styles | StylesOptions | null | The styles to use for the component. |
| children | ReactNode \\| ((instance: AccordionHeaderIndicatorInstance) => ReactNode) | null | The children to render. |
| [key: string] | any | null | |
| pt-{optionName}-* | - | null | Pass through attributes for customizing component. For more info, see Pass Through tab. |
### Exposes
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| accordion | AccordionInstance | null | The Accordion component instance. |
| accordionpanel | AccordionPanelInstance | null | The AccordionPanel component instance. |
### Interfaces
| Label | Description | Data |
|:------|:------|:------|
| PassThroughOptions | Defines passthrough(pt) options of AccordionHeaderIndicator component. | [object Object] |
### Types
| Label | Description | Data |
|:------|:------|:------|
| Instance | Instance of AccordionHeaderIndicator component. | [object Object] |
## AccordionContent
### Props
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| ref | Ref | null | The reference to the component instance. |
| pIf | boolean | true | Whether the component should be rendered. |
| style | CSSProperties \\| ((instance?: AccordionContentInstance) => CSSProperties) | null | The style to apply to the component. |
| className | string \\| ((instance?: AccordionContentInstance) => string) | null | The class name to apply to the component. |
| as | string \\| number \\| bigint \\| boolean \\| ComponentClass \\| FunctionComponent \\| ReactElement> \\| Iterable \\| ReactPortal \\| Promise | null | The component type to render. |
| asChild | boolean | false | Whether the component should be rendered as a child component. |
| pt | SafeRecord | null | The pass-through props to pass to the component |
| ptOptions | PassThroughOptions | null | The pass-through options to pass to the component |
| unstyled | boolean | null | Whether the component should be rendered without classes. |
| dt | unknown | null | The design token to use for the component. |
| styles | StylesOptions | null | The styles to use for the component. |
| children | ReactNode \\| ((instance: AccordionContentInstance) => ReactNode) | null | The children to render. |
| [key: string] | any | null | |
| pt-{optionName}-* | - | null | Pass through attributes for customizing component. For more info, see Pass Through tab. |
### Exposes
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| accordion | AccordionInstance | null | The Accordion component instance. |
### Types
| Label | Description | Data |
|:------|:------|:------|
| Instance | Instance of AccordionContent component. | [object Object] |
# Accordion
Accordion groups a collection of contents in panels.
## Usage
```tsx
import { Accordion } from 'primereact/accordion';
```
```tsx
Title
Content
```
## Examples
### Basic
Accordion is defined using `Accordion`, `Accordion.Panel`, `Accordion.Header`, `Accordion.HeaderIndicator` and `Accordion.Content` components. Each `Accordion.Panel` must contain a unique `value` property to specify the active item.
```tsx
import { Accordion } from 'primereact/accordion';
export default function BasicDemo() {
return (
What is this service about?
This service helps you manage your projects more efficiently by offering real-time collaboration, task tracking, and powerful analytics. Whether you’re working solo or in a team, it’s built to scale with your needs.
Is my data secure?
Yes. We use end-to-end encryption and follow industry best practices to ensure your data is protected. Your information is stored on secure servers and regularly backed up.
Can I upgrade or downgrade my plan later?
Absolutely. You can change your subscription plan at any time from your account settings. Changes take effect immediately, and any billing adjustments are handled automatically.
);
}
```
### Multiple
Only one tab at a time can be active by default, enabling `multiple` property changes this behavior to allow multiple panels. In this case `multiple` needs to be an array.
```tsx
import { Accordion } from 'primereact/accordion';
export default function MultipleDemo() {
return (
What is this service about?
This service helps you manage your projects more efficiently by offering real-time collaboration, task tracking, and powerful analytics. Whether you’re working solo or in a team, it’s built to scale with your needs.
Is my data secure?
Yes. We use end-to-end encryption and follow industry best practices to ensure your data is protected. Your information is stored on secure servers and regularly backed up.
Can I upgrade or downgrade my plan later?
Absolutely. You can change your subscription plan at any time from your account settings. Changes take effect immediately, and any billing adjustments are handled automatically.
);
}
```
### Custom Indicator
The `Accordion.HeaderIndicator` component is used to display the indicator of the header. It can be customized by passing a function that returns a React element or `data-p-active` attribute.
```tsx
import { MinusIcon, PlusIcon } from '@primereact/icons';
import type { AccordionHeaderIndicatorInstance } from '@primereact/types/shared/accordion';
import { Accordion } from 'primereact/accordion';
export default function CustomIndicatorDemo() {
return (
What is this service about?
This service helps you manage your projects more efficiently by offering real-time collaboration, task tracking, and powerful analytics. Whether you're working solo or in a team, it's built to scale with your
needs.
Is my data secure?
{({ accordionpanel }: AccordionHeaderIndicatorInstance) => (accordionpanel?.active ? : )}
Yes. We use end-to-end encryption and follow industry best practices to ensure your data is protected. Your information is stored on secure servers and regularly backed up.
Can I upgrade or downgrade my plan later?
Absolutely. You can change your subscription plan at any time from your account settings. Changes take effect immediately, and any billing adjustments are handled automatically.
);
}
```
### Disabled
Enabling `disabled` property of an `Accordion.Panel` prevents user interaction of the panel or enable `disabled` of the `Accordion` component disables all panels.
```tsx
import { Accordion } from 'primereact/accordion';
export default function DisabledDemo() {
return (
How do I reset my password?
You can reset your password by clicking the “Forgot password?” link on the login page. We’ll send a password reset link to your registered email address.
Do you offer team accounts?
Yes. Our Team and Business plans are designed for collaboration. You can invite team members, assign roles, and manage permissions easily from your dashboard.
What happens if I exceed my usage limit?
If you go over your plan limits (e.g., storage or API requests), you’ll receive a notification. You can either upgrade your plan or wait until the next billing cycle resets.
Is there a mobile app available?
Yes, we offer both iOS and Android apps so you can manage your account and stay connected on the go.
);
}
```
### Template
The optional `as` property controls the default container element of a header, for example setting it to a div renders a div for the header instead of a button. The `asChild` option enables the headless mode for further customization by passing callbacks and properties to implement your own header.
```tsx
import { Icon } from '@primereact/core/icon';
import type { AccordionHeaderInstance } from '@primereact/types/shared/accordion';
import { Accordion } from 'primereact/accordion';
const items = [
{
label: 'What is this service about?',
value: '1',
icon: 'pi pi-question-circle text-yellow-500',
content: 'This service helps you manage your projects more efficiently by offering real-time collaboration, task tracking, and powerful analytics. Whether you’re working solo or in a team, it’s built to scale with your needs.'
},
{
label: 'Is my data secure?',
value: '2',
icon: 'pi pi-lock text-blue-500',
content: 'Yes. We use end-to-end encryption and follow industry best practices to ensure your data is protected. Your information is stored on secure servers and regularly backed up.'
},
{
label: 'Can I upgrade or downgrade my plan later?',
value: '3',
icon: 'pi pi-credit-card text-green-500',
content: 'Absolutely. You can change your subscription plan at any time from your account settings. Changes take effect immediately, and any billing adjustments are handled automatically.'
}
];
export default function TemplateDemo() {
return (
);
}
```
### With RadioButton
`RadioButton` component can be used to group multiple `Accordion.Panel` components.
```tsx
import type { useAccordionChangeEvent } from '@primereact/types/shared/accordion';
import type { RadioButtonGroupValueChangeEvent } from '@primereact/types/shared/radiobutton';
import { Accordion } from 'primereact/accordion';
import { Button } from 'primereact/button';
import { RadioButton } from 'primereact/radiobutton';
import * as React from 'react';
const items = [
{
label: 'Starter Plan',
description: 'Perfect for individuals getting started. Includes access to core components and community support.',
value: '1',
price: '$99'
},
{
label: 'Growth Plan',
description: 'Ideal for freelancers and small teams. Unlocks advanced UI components and priority email support.',
value: '2',
price: '$249'
},
{
label: 'Scale Plan',
description: 'Best for growing businesses. Includes all features, early access to new releases, and Slack support.',
value: '3',
price: '$499'
}
];
export default function UseWithRadioButton() {
const [selected, setSelected] = React.useState('1');
return (
);
}
```
## Accessibility
### Screen Reader
Accordion header elements is a button element and use aria-controls to define the id of the content section along with aria-expanded for the visibility state. The value to read a header element defaults to the value of the header property and can be customized by defining an aria-label or aria-labelledby via the pt property.
The content uses region role, defines an id that matches the aria-controls of the header and aria-labelledby referring to the id of the header.
### Header Keyboard Support
| Key | Function |
| ------------- | ---------------------------------------------------------------------------------------------------- |
| `tab` | Moves focus to the next focusable element in the page tab sequence. |
| `shift + tab` | Moves focus to the previous focusable element in the page tab sequence. |
| `enter` | Toggles the visibility of the content. |
| `space` | Toggles the visibility of the content. |
| `down arrow` | Moves focus to the next header. If focus is on the last header, moves focus to the first header. |
| `up arrow` | Moves focus to the previous header. If focus is on the first header, moves focus to the last header. |
| `home` | Moves focus to the first header. |
| `end` | Moves focus to the last header. |
# Accordion Pass Through
Pass Through documentation for accordion component
## Viewer
Some sections may not be visible due to the availability of the particular feature.
## Accordion PT Options
| Label | Type | Description |
|:------|:------|:------|
| root | AccordionPassThroughType> | Used to pass attributes to the root's DOM element. |
| panel | AccordionPassThroughType> | Used to pass attributes to the panel's DOM element. |
| header | AccordionPassThroughType> | Used to pass attributes to the header's DOM element. |
| content | AccordionPassThroughType> | Used to pass attributes to the content's DOM element. |
| headerindicator | AccordionPassThroughType> | Used to pass attributes to the header indicator's DOM element. |
## AccordionPanel PT Options
| Label | Type | Description |
|:------|:------|:------|
| root | AccordionPanelPassThroughType> | Used to pass attributes to the root's DOM element. |
## AccordionHeader PT Options
| Label | Type | Description |
|:------|:------|:------|
| root | AccordionHeaderPassThroughType> | Used to pass attributes to the root's DOM element. |
## AccordionHeaderIndicator PT Options
| Label | Type | Description |
|:------|:------|:------|
| root | AccordionHeaderIndicatorPassThroughType> | Used to pass attributes to the root's DOM element. |
## AccordionContent PT Options
| Label | Type | Description |
|:------|:------|:------|
| root | AccordionContentPassThroughType> | Used to pass attributes to the root's DOM element. |
# Accordion Theming
Theming documentation for accordion component
## Styled
### Accordion CSS Classes
List of class names used in the styled mode.
| ClassName | Description |
|:------|:------|
| p-accordion | Class name of the root element |
| p-accordioncontent | Class name of the content element |
| p-accordionheader | Class name of the header element |
| p-accordionpanel | Class name of the panel element |
| p-accordionheader-toggle-icon | Class name of the toggle icon element |
### Design Tokens
List of design tokens.
| Token | CSS Variable | Description |
|:------|:------|:------|
| accordion.transition.duration | --p-accordion-transition-duration | Transition duration of root |
| accordion.panel.border.width | --p-accordion-panel-border-width | Border width of panel |
| accordion.panel.border.color | --p-accordion-panel-border-color | Border color of panel |
| accordion.header.color | --p-accordion-header-color | Color of header |
| accordion.header.hover.color | --p-accordion-header-hover-color | Hover color of header |
| accordion.header.active.color | --p-accordion-header-active-color | Active color of header |
| accordion.header.active.hover.color | --p-accordion-header-active-hover-color | Active hover color of header |
| accordion.header.padding | --p-accordion-header-padding | Padding of header |
| accordion.header.font.weight | --p-accordion-header-font-weight | Font weight of header |
| accordion.header.border.radius | --p-accordion-header-border-radius | Border radius of header |
| accordion.header.border.width | --p-accordion-header-border-width | Border width of header |
| accordion.header.border.color | --p-accordion-header-border-color | Border color of header |
| accordion.header.background | --p-accordion-header-background | Background of header |
| accordion.header.hover.background | --p-accordion-header-hover-background | Hover background of header |
| accordion.header.active.background | --p-accordion-header-active-background | Active background of header |
| accordion.header.active.hover.background | --p-accordion-header-active-hover-background | Active hover background of header |
| accordion.header.focus.ring.width | --p-accordion-header-focus-ring-width | Focus ring width of header |
| accordion.header.focus.ring.style | --p-accordion-header-focus-ring-style | Focus ring style of header |
| accordion.header.focus.ring.color | --p-accordion-header-focus-ring-color | Focus ring color of header |
| accordion.header.focus.ring.offset | --p-accordion-header-focus-ring-offset | Focus ring offset of header |
| accordion.header.focus.ring.shadow | --p-accordion-header-focus-ring-shadow | Focus ring shadow of header |
| accordion.header.toggle.icon.color | --p-accordion-header-toggle-icon-color | Toggle icon color of header |
| accordion.header.toggle.icon.hover.color | --p-accordion-header-toggle-icon-hover-color | Toggle icon hover color of header |
| accordion.header.toggle.icon.active.color | --p-accordion-header-toggle-icon-active-color | Toggle icon active color of header |
| accordion.header.toggle.icon.active.hover.color | --p-accordion-header-toggle-icon-active-hover-color | Toggle icon active hover color of header |
| accordion.header.first.top.border.radius | --p-accordion-header-first-top-border-radius | First top border radius of header |
| accordion.header.first.border.width | --p-accordion-header-first-border-width | First border width of header |
| accordion.header.last.bottom.border.radius | --p-accordion-header-last-bottom-border-radius | Last bottom border radius of header |
| accordion.header.last.active.bottom.border.radius | --p-accordion-header-last-active-bottom-border-radius | Last active bottom border radius of header |
| accordion.content.border.width | --p-accordion-content-border-width | Border width of content |
| accordion.content.border.color | --p-accordion-content-border-color | Border color of content |
| accordion.content.background | --p-accordion-content-background | Background of content |
| accordion.content.color | --p-accordion-content-color | Color of content |
| accordion.content.padding | --p-accordion-content-padding | Padding of content |
## Unstyled
Theming is implemented with the pass through properties in unstyled mode.
# AnimateOnScroll
AnimateOnScroll is used to apply animations to elements when entering or leaving the viewport during scrolling.
## Usage
```tsx
import { AnimateOnScroll } from 'primereact/animateonscroll';
```
```tsx
Animated Element
```
## Examples
### Basic
## Accessibility
### Screen Reader
AnimateOnScroll does not require any roles and attributes.
### Keyboard Support
Component does not include any interactive elements.
# Avatar API
API documentation for Avatar component
## Avatar
### Props
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| ref | Ref | null | The reference to the component instance. |
| pIf | boolean | true | Whether the component should be rendered. |
| style | CSSProperties \\| ((instance?: AvatarInstance) => CSSProperties) | null | The style to apply to the component. |
| className | string \\| ((instance?: AvatarInstance) => string) | null | The class name to apply to the component. |
| as | string \\| number \\| bigint \\| boolean \\| ComponentClass \\| FunctionComponent \\| ReactElement> \\| Iterable \\| ReactPortal \\| Promise | null | The component type to render. |
| asChild | boolean | false | Whether the component should be rendered as a child component. |
| pt | SafeRecord | null | The pass-through props to pass to the component |
| ptOptions | PassThroughOptions | null | The pass-through options to pass to the component |
| unstyled | boolean | null | Whether the component should be rendered without classes. |
| dt | unknown | null | The design token to use for the component. |
| styles | StylesOptions | null | The styles to use for the component. |
| children | ReactNode \\| ((instance: AvatarInstance) => ReactNode) | null | The children to render. |
| size | "large" \\| "normal" \\| "xlarge" | normal | Defines the size of the avatar. |
| shape | "circle" \\| "square" | square | Defines the shape of the avatar. |
| delayDuration | number | null | The delay duration of the avatar. |
| [key: string] | any | null | |
| pt-{optionName}-* | - | null | Pass through attributes for customizing component. For more info, see Pass Through tab. |
### State
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| load | boolean | null | Whether the avatar's image is loading or not. |
### Exposes
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| state | useAvatarState | null | The state of the useAvatar. |
| handleImageLoad | (src?: string) => void | null | The method to handle image load. |
| handleImageUnload | () => void | null | The method to handle image unload. |
### Interfaces
| Label | Description | Data |
|:------|:------|:------|
| PassThroughOptions | Defines passthrough(pt) options of Avatar component. | [object Object],[object Object],[object Object] |
### Types
| Label | Description | Data |
|:------|:------|:------|
| Instance | Instance of Avatar component. | [object Object] |
## AvatarFallback
### Props
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| ref | Ref | null | The reference to the component instance. |
| pIf | boolean | true | Whether the component should be rendered. |
| style | CSSProperties \\| ((instance?: AvatarFallbackInstance) => CSSProperties) | null | The style to apply to the component. |
| className | string \\| ((instance?: AvatarFallbackInstance) => string) | null | The class name to apply to the component. |
| as | string \\| number \\| bigint \\| boolean \\| ComponentClass \\| FunctionComponent \\| ReactElement> \\| Iterable \\| ReactPortal \\| Promise | null | The component type to render. |
| asChild | boolean | false | Whether the component should be rendered as a child component. |
| pt | SafeRecord | null | The pass-through props to pass to the component |
| ptOptions | PassThroughOptions | null | The pass-through options to pass to the component |
| unstyled | boolean | null | Whether the component should be rendered without classes. |
| dt | unknown | null | The design token to use for the component. |
| styles | StylesOptions | null | The styles to use for the component. |
| children | ReactNode \\| ((instance: AvatarFallbackInstance) => ReactNode) | null | The children to render. |
| [key: string] | any | null | |
| pt-{optionName}-* | - | null | Pass through attributes for customizing component. For more info, see Pass Through tab. |
### Exposes
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| avatar | AvatarInstance | null | The Avatar component instance. |
### Interfaces
| Label | Description | Data |
|:------|:------|:------|
| PassThroughOptions | Defines passthrough(pt) options of AvatarFallback component. | [object Object] |
### Types
| Label | Description | Data |
|:------|:------|:------|
| Instance | Instance of AvatarFallback component. | [object Object] |
## AvatarImage
### Props
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| ref | Ref | null | The reference to the component instance. |
| pIf | boolean | true | Whether the component should be rendered. |
| style | CSSProperties \\| ((instance?: AvatarImageInstance) => CSSProperties) | null | The style to apply to the component. |
| className | string \\| ((instance?: AvatarImageInstance) => string) | null | The class name to apply to the component. |
| as | ReactNode | null | The component type to render. |
| asChild | boolean | false | Whether the component should be rendered as a child component. |
| pt | SafeRecord | null | The pass-through props to pass to the component |
| ptOptions | PassThroughOptions | null | The pass-through options to pass to the component |
| unstyled | boolean | null | Whether the component should be rendered without classes. |
| dt | unknown | null | The design token to use for the component. |
| styles | StylesOptions | null | The styles to use for the component. |
| children | ReactNode \\| ((instance: AvatarImageInstance) => ReactNode) | null | The children to render. |
| src | string | null | Specifies the path to the image to display. |
| pt-{optionName}-* | - | null | Pass through attributes for customizing component. For more info, see Pass Through tab. |
### Exposes
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| avatar | AvatarInstance | null | The Avatar component instance. |
### Interfaces
| Label | Description | Data |
|:------|:------|:------|
| PassThroughOptions | Defines passthrough(pt) options of AvatarImage component. | [object Object] |
### Types
| Label | Description | Data |
|:------|:------|:------|
| Instance | Instance of AvatarImage component. | [object Object] |
## AvatarGroup
### Props
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| ref | Ref | null | The reference to the component instance. |
| pIf | boolean | true | Whether the component should be rendered. |
| style | CSSProperties \\| ((instance?: AvatarGroupInstance) => CSSProperties) | null | The style to apply to the component. |
| className | string \\| ((instance?: AvatarGroupInstance) => string) | null | The class name to apply to the component. |
| as | string \\| number \\| bigint \\| boolean \\| ComponentClass \\| FunctionComponent \\| ReactElement> \\| Iterable \\| ReactPortal \\| Promise | null | The component type to render. |
| asChild | boolean | false | Whether the component should be rendered as a child component. |
| pt | SafeRecord | null | The pass-through props to pass to the component |
| ptOptions | PassThroughOptions | null | The pass-through options to pass to the component |
| unstyled | boolean | null | Whether the component should be rendered without classes. |
| dt | unknown | null | The design token to use for the component. |
| styles | StylesOptions | null | The styles to use for the component. |
| children | ReactNode \\| ((instance: AvatarGroupInstance) => ReactNode) | null | The children to render. |
| [key: string] | any | null | |
| pt-{optionName}-* | - | null | Pass through attributes for customizing component. For more info, see Pass Through tab. |
### Interfaces
| Label | Description | Data |
|:------|:------|:------|
| PassThroughOptions | Defines passthrough(pt) options of AvatarGroup component. | [object Object] |
### Types
| Label | Description | Data |
|:------|:------|:------|
| Instance | Instance of AvatarGroup component. | [object Object] |
## useAvatar
### Props
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| delayDuration | number | null | The delay duration of the avatar. |
### State
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| load | boolean | null | Whether the avatar's image is loading or not. |
### Exposes
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| state | useAvatarState | null | The state of the useAvatar. |
| handleImageLoad | (src?: string) => void | null | The method to handle image load. |
| handleImageUnload | () => void | null | The method to handle image unload. |
### Events
### Types
| Label | Description | Data |
|:------|:------|:------|
| Instance | Instance of useAvatar headless. | [object Object] |
# Avatar
Avatar represents people using icons, labels and images.
## Usage
```tsx
import { Avatar } from 'primereact/avatar';
```
```tsx
CC
```
## Examples
### Fallback
The `Avatar.Fallback` component displays a label or an icon when an image fails to load or when an image is not preferred.
```tsx
import { CheckIcon } from '@primereact/icons';
import { Avatar } from 'primereact/avatar';
export default function LabelDemo() {
return (
JCC
);
}
```
### Image
The `Avatar.Image` component displays an image as an Avatar.
```tsx
import { Avatar } from 'primereact/avatar';
export default function ImageDemo() {
return (
AAO
);
}
```
### Badge
[`Badge`](/docs/components/badge) component can be used to display a badge on an Avatar.
```tsx
import { Avatar } from 'primereact/avatar';
import { Badge } from 'primereact/badge';
const BadgeDemo = () => {
return (
O
2
W
);
};
export default BadgeDemo;
```
### Shape
Use the `shape` property to change the appearance.
```tsx
import { Avatar } from 'primereact/avatar';
const ShapeDemo = () => {
return (
WW
);
};
export default ShapeDemo;
```
### Sizes
Use the `size` property to change the size of an avatar.
```tsx
import { Avatar } from 'primereact/avatar';
const SizeDemo = () => {
return (
CCCCCC
);
};
export default SizeDemo;
```
### AvatarGroup
Grouping is available by wrapping multiple Avatar components inside an `Avatar.Group` component.
```tsx
import { Avatar } from 'primereact/avatar';
export default function GroupDemo() {
return (
AAOIX+2
);
}
```
## Accessibility
### Screen Reader
Avatar does not include any roles and attributes by default. Any attribute is passed to the root element so you may add a role like img along with aria-labelledby or aria-label to describe the component. In case avatars need to be tabbable, tabindex can be added as well to implement custom key handlers.
### Keyboard Support
Component does not include any interactive elements.
# Avatar Pass Through
Pass Through documentation for avatar component
## Viewer
Some sections may not be visible due to the availability of the particular feature.
## Avatar PT Options
| Label | Type | Description |
|:------|:------|:------|
| root | AvatarPassThroughType> | Used to pass attributes to the root's DOM element. |
| fallback | AvatarPassThroughType> | Used to pass attributes to the fallback's DOM element. |
| image | AvatarPassThroughType> | Used to pass attributes to the image's DOM element. |
## AvatarFallback PT Options
| Label | Type | Description |
|:------|:------|:------|
| root | AvatarFallbackPassThroughType> | Used to pass attributes to the root's DOM element. |
## AvatarImage PT Options
| Label | Type | Description |
|:------|:------|:------|
| root | AvatarImagePassThroughType> | Used to pass attributes to the root's DOM element. |
## AvatarGroup PT Options
| Label | Type | Description |
|:------|:------|:------|
| root | AvatarGroupPassThroughType> | Used to pass attributes to the root's DOM element. |
# Avatar Theming
Theming documentation for avatar component
## Styled
### Avatar CSS Classes
List of class names used in the styled mode.
| ClassName | Description |
|:------|:------|
| p-avatar | Class name of the root element |
| p-avatar-label | Class name of the box element |
| p-avatar-icon | Class name of the input element |
### AvatarGroup CSS Classes
List of class names used in the styled mode.
| ClassName | Description |
|:------|:------|
| p-avatar-group | Class name of the root element |
### Design Tokens
List of design tokens.
| Token | CSS Variable | Description |
|:------|:------|:------|
| avatar.width | --p-avatar-width | Width of root |
| avatar.height | --p-avatar-height | Height of root |
| avatar.font.size | --p-avatar-font-size | Font size of root |
| avatar.background | --p-avatar-background | Background of root |
| avatar.color | --p-avatar-color | Color of root |
| avatar.border.radius | --p-avatar-border-radius | Border radius of root |
| avatar.icon.size | --p-avatar-icon-size | Size of icon |
| avatar.group.border.color | --p-avatar-group-border-color | Border color of group |
| avatar.group.offset | --p-avatar-group-offset | Offset of group |
| avatar.lg.width | --p-avatar-lg-width | Width of lg |
| avatar.lg.height | --p-avatar-lg-height | Height of lg |
| avatar.lg.font.size | --p-avatar-lg-font-size | Font size of lg |
| avatar.lg.icon.size | --p-avatar-lg-icon-size | Icon size of lg |
| avatar.lg.group.offset | --p-avatar-lg-group-offset | Group offset of lg |
| avatar.xl.width | --p-avatar-xl-width | Width of xl |
| avatar.xl.height | --p-avatar-xl-height | Height of xl |
| avatar.xl.font.size | --p-avatar-xl-font-size | Font size of xl |
| avatar.xl.icon.size | --p-avatar-xl-icon-size | Icon size of xl |
| avatar.xl.group.offset | --p-avatar-xl-group-offset | Group offset of xl |
## Unstyled
Theming is implemented with the pass through properties in unstyled mode.
# Badge API
API documentation for Badge component
## Badge
### Props
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| ref | Ref | null | The reference to the component instance. |
| pIf | boolean | true | Whether the component should be rendered. |
| style | CSSProperties \\| ((instance?: BadgeInstance) => CSSProperties) | null | The style to apply to the component. |
| className | string \\| ((instance?: BadgeInstance) => string) | null | The class name to apply to the component. |
| as | string \\| number \\| bigint \\| boolean \\| ComponentClass \\| FunctionComponent \\| ReactElement> \\| Iterable \\| ReactPortal \\| Promise | null | The component type to render. |
| asChild | boolean | false | Whether the component should be rendered as a child component. |
| pt | SafeRecord | null | The pass-through props to pass to the component |
| ptOptions | PassThroughOptions | null | The pass-through options to pass to the component |
| unstyled | boolean | null | Whether the component should be rendered without classes. |
| dt | unknown | null | The design token to use for the component. |
| styles | StylesOptions | null | The styles to use for the component. |
| children | ReactNode \\| ((instance: BadgeInstance) => ReactNode) | null | The children to render. |
| shape | "circle" | null | Defines the shape of the badge. |
| size | "small" \\| "large" \\| "xlarge" | null | Size of the badge. |
| severity | "secondary" \\| "info" \\| "success" \\| "warn" \\| "danger" \\| "contrast" | null | Severity type of the badge. |
| [key: string] | any | null | |
| pt-{optionName}-* | - | null | Pass through attributes for customizing component. For more info, see Pass Through tab. |
### Interfaces
| Label | Description | Data |
|:------|:------|:------|
| PassThroughOptions | Defines passthrough(pt) options of Badge component. | [object Object] |
### Types
| Label | Description | Data |
|:------|:------|:------|
| Instance | Instance of Badge component. | [object Object] |
## OverlayBadge
### Props
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| ref | Ref | null | The reference to the component instance. |
| pIf | boolean | true | Whether the component should be rendered. |
| style | CSSProperties \\| ((instance?: OverlayBadgeInstance) => CSSProperties) | null | The style to apply to the component. |
| className | string \\| ((instance?: OverlayBadgeInstance) => string) | null | The class name to apply to the component. |
| as | string \\| number \\| bigint \\| boolean \\| ComponentClass \\| FunctionComponent \\| ReactElement> \\| Iterable \\| ReactPortal \\| Promise | null | The component type to render. |
| asChild | boolean | false | Whether the component should be rendered as a child component. |
| pt | SafeRecord | null | The pass-through props to pass to the component |
| ptOptions | PassThroughOptions | null | The pass-through options to pass to the component |
| unstyled | boolean | null | Whether the component should be rendered without classes. |
| dt | unknown | null | The design token to use for the component. |
| styles | StylesOptions | null | The styles to use for the component. |
| children | ReactNode \\| ((instance: OverlayBadgeInstance) => ReactNode) | null | The children to render. |
| [key: string] | any | null | |
| pt-{optionName}-* | - | null | Pass through attributes for customizing component. For more info, see Pass Through tab. |
### Interfaces
| Label | Description | Data |
|:------|:------|:------|
| PassThroughOptions | Defines passthrough(pt) options of OverlayBadge component. | [object Object] |
### Types
| Label | Description | Data |
|:------|:------|:------|
| Instance | Instance of OverlayBadge component. | [object Object] |
## useBadge
### Types
| Label | Description | Data |
|:------|:------|:------|
| Instance | Instance of useBadge headless. | [object Object] |
# Badge
Badge is a small status indicator for another element.
## Usage
```tsx
import { Badge } from 'primereact/badge';
```
```tsx
Badge
```
## Examples
### Basic
```tsx
import { Badge } from 'primereact/badge';
export default function BasicDemo() {
return (
Badge
);
}
```
### Severity
The `severity` property defines the visual style of a badge.
```tsx
import { Badge } from 'primereact/badge';
export default function SeverityDemo() {
return (
DefaultSecondarySuccessInfoWarningDangerContrast
);
}
```
### Size
Use the `size` property to change the size of a badge.
```tsx
import { Badge } from 'primereact/badge';
export default function SizeDemo() {
return (
SmallDefaultLargeXLarge
);
}
```
### Overlay
A badge can be added to any element by encapsulating the content with the `Badge.Overlay` component.
```tsx
import { Badge } from 'primereact/badge';
export default function BasicDemo() {
return (
2
4
);
}
```
### Button
Buttons have built-in support for badges to display a badge inline.
```tsx
import { Badge } from 'primereact/badge';
import { Button } from 'primereact/button';
export default function ButtonDemo() {
return (
);
}
```
## Accessibility
### Screen Reader
Badge does not include any roles and attributes by default, any attribute is passed to the root element so aria roles and attributes can be added if required. If the badges are dynamic, _aria-live_ may be utilized as well. In case badges need to be tabbable, _tabindex_ can be added to implement custom key handlers.
### Keyboard Support
Component does not include any interactive elements.
# Badge Pass Through
Pass Through documentation for Badge component
## Viewer
Some sections may not be visible due to the availability of the particular feature.
## Badge PT Options
| Label | Type | Description |
|:------|:------|:------|
| root | BadgePassThroughType> | Used to pass attributes to the root's DOM element. |
## OverlayBadge PT Options
| Label | Type | Description |
|:------|:------|:------|
| root | OverlayBadgePassThroughType> | Used to pass attributes to the root's DOM element. |
# Badge Theming
Theming documentation for badge component
## Styled
### Badge CSS Classes
List of class names used in the styled mode.
| ClassName | Description |
|:------|:------|
| p-badge | Class name of the root element |
### OverlayBadge CSS Classes
List of class names used in the styled mode.
| ClassName | Description |
|:------|:------|
| p-overlaybadge | Class name of the root element |
### Design Tokens
List of design tokens.
| Token | CSS Variable | Description |
|:------|:------|:------|
| badge.border.radius | --p-badge-border-radius | Border radius of root |
| badge.padding | --p-badge-padding | Padding of root |
| badge.font.size | --p-badge-font-size | Font size of root |
| badge.font.weight | --p-badge-font-weight | Font weight of root |
| badge.min.width | --p-badge-min-width | Min width of root |
| badge.height | --p-badge-height | Height of root |
| badge.dot.size | --p-badge-dot-size | Size of dot |
| badge.sm.font.size | --p-badge-sm-font-size | Font size of sm |
| badge.sm.min.width | --p-badge-sm-min-width | Min width of sm |
| badge.sm.height | --p-badge-sm-height | Height of sm |
| badge.lg.font.size | --p-badge-lg-font-size | Font size of lg |
| badge.lg.min.width | --p-badge-lg-min-width | Min width of lg |
| badge.lg.height | --p-badge-lg-height | Height of lg |
| badge.xl.font.size | --p-badge-xl-font-size | Font size of xl |
| badge.xl.min.width | --p-badge-xl-min-width | Min width of xl |
| badge.xl.height | --p-badge-xl-height | Height of xl |
| badge.primary.background | --p-badge-primary-background | Background of primary |
| badge.primary.color | --p-badge-primary-color | Color of primary |
| badge.secondary.background | --p-badge-secondary-background | Background of secondary |
| badge.secondary.color | --p-badge-secondary-color | Color of secondary |
| badge.success.background | --p-badge-success-background | Background of success |
| badge.success.color | --p-badge-success-color | Color of success |
| badge.info.background | --p-badge-info-background | Background of info |
| badge.info.color | --p-badge-info-color | Color of info |
| badge.warn.background | --p-badge-warn-background | Background of warn |
| badge.warn.color | --p-badge-warn-color | Color of warn |
| badge.danger.background | --p-badge-danger-background | Background of danger |
| badge.danger.color | --p-badge-danger-color | Color of danger |
| badge.contrast.background | --p-badge-contrast-background | Background of contrast |
| badge.contrast.color | --p-badge-contrast-color | Color of contrast |
## Unstyled
Theming is implemented with the pass through properties in unstyled mode.
# Button API
API documentation for Button component
## Button
### Props
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| ref | Ref | null | The reference to the component instance. |
| pIf | boolean | true | Whether the component should be rendered. |
| style | CSSProperties \\| ((instance?: ButtonInstance) => CSSProperties) | null | The style to apply to the component. |
| className | string \\| ((instance?: ButtonInstance) => string) | null | The class name to apply to the component. |
| as | string \\| number \\| bigint \\| boolean \\| ComponentClass \\| FunctionComponent \\| ReactElement> \\| Iterable \\| ReactPortal \\| Promise | null | The component type to render. |
| asChild | boolean | false | Whether the component should be rendered as a child component. |
| pt | SafeRecord | null | The pass-through props to pass to the component |
| ptOptions | PassThroughOptions | null | The pass-through options to pass to the component |
| unstyled | boolean | null | Whether the component should be rendered without classes. |
| dt | unknown | null | The design token to use for the component. |
| styles | StylesOptions | null | The styles to use for the component. |
| children | ReactNode \\| ((instance: ButtonInstance) => ReactNode) | null | The children to render. |
| size | "small" \\| "large" \\| "normal" | null | Size of the Button. |
| severity | string & {} \\| "secondary" \\| "info" \\| "success" \\| "warn" \\| "danger" \\| "contrast" \\| "help" | null | Severity type of the Button. |
| variant | "link" \\| "text" \\| "outlined" | null | Variant of the Button. |
| plain | boolean | null | Whether to show the Button with a plain style. |
| rounded | boolean | null | Whether to show the Button with a rounded style. |
| raised | boolean | null | Whether to show the Button with a raised style. |
| iconOnly | boolean | null | Whether to show the Button with a borderless style. |
| fluid | boolean | null | Whether to show the Button with a fluid width. |
| [key: string] | any | null | |
| pt-{optionName}-* | - | null | Pass through attributes for customizing component. For more info, see Pass Through tab. |
### Interfaces
| Label | Description | Data |
|:------|:------|:------|
| PassThroughOptions | Defines passthrough(pt) options of Button component. | [object Object] |
### Types
| Label | Description | Data |
|:------|:------|:------|
| Instance | Instance of Button component. | [object Object] |
## ButtonGroup
### Props
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| ref | Ref | null | The reference to the component instance. |
| pIf | boolean | true | Whether the component should be rendered. |
| style | CSSProperties \\| ((instance?: ButtonGroupInstance) => CSSProperties) | null | The style to apply to the component. |
| className | string \\| ((instance?: ButtonGroupInstance) => string) | null | The class name to apply to the component. |
| as | string \\| number \\| bigint \\| boolean \\| ComponentClass \\| FunctionComponent \\| ReactElement> \\| Iterable \\| ReactPortal \\| Promise | null | The component type to render. |
| asChild | boolean | false | Whether the component should be rendered as a child component. |
| pt | SafeRecord | null | The pass-through props to pass to the component |
| ptOptions | PassThroughOptions | null | The pass-through options to pass to the component |
| unstyled | boolean | null | Whether the component should be rendered without classes. |
| dt | unknown | null | The design token to use for the component. |
| styles | StylesOptions | null | The styles to use for the component. |
| children | ReactNode \\| ((instance: ButtonGroupInstance) => ReactNode) | null | The children to render. |
| [key: string] | any | null | |
| pt-{optionName}-* | - | null | Pass through attributes for customizing component. For more info, see Pass Through tab. |
### Interfaces
| Label | Description | Data |
|:------|:------|:------|
| PassThroughOptions | Defines passthrough(pt) options of Button component. | [object Object] |
### Types
| Label | Description | Data |
|:------|:------|:------|
| Instance | Instance of ButtonGroup component. | [object Object] |
## useButton
### Types
| Label | Description | Data |
|:------|:------|:------|
| Instance | Instance of useButton headless. | [object Object] |
# Button
Button is an extension to standard input element with icons and theming.
## Usage
```tsx
import { Button } from 'primereact/button';
```
```tsx
```
## Examples
### Basic
```tsx
import { Button } from 'primereact/button';
export default function BasicDemo() {
return (
);
}
```
### Icons
```tsx
import { Button } from 'primereact/button';
export default function IconDemo() {
return (
);
}
```
### As Link
Use `as="a"` to render a button as HTML anchor tag or use `as={Link}` to use Next.js Link.
```tsx
import Link from 'next/link';
import { Button } from 'primereact/button';
export default function LinkDemo() {
return (
);
}
```
### Severity
The `severity` property defines the variant of a button.
```tsx
import { Button } from 'primereact/button';
export default function SeverityDemo() {
return (
);
}
```
### Disabled
When `disabled` is present, the element cannot be used.
```tsx
import { Button } from 'primereact/button';
export default function DisabledDemo() {
return (
);
}
```
### Raised
Raised buttons display a shadow to indicate elevation.
```tsx
import { Button } from 'primereact/button';
export default function RaisedDemo() {
return (
);
}
```
### Rounded
Rounded buttons have a circular border radius.
```tsx
import { Button } from 'primereact/button';
export default function RoundedDemo() {
return (
);
}
```
### Text
Text buttons are displayed as textual elements.
```tsx
import { Button } from 'primereact/button';
export default function TextDemo() {
return (
);
}
```
### Raised Text
Text buttons can be displayed elevated with the `raised` option.
```tsx
import { Button } from 'primereact/button';
export default function RaisedTextDemo() {
return (
);
}
```
### Outlined
Outlined buttons display a border without a transparent background.
```tsx
import { Button } from 'primereact/button';
export default function OutlinedDemo() {
return (
);
}
```
### Icon Only
Buttons can have icons without labels. Use `iconOnly` to display only an icon.
```tsx
import { Button } from 'primereact/button';
import { useState } from 'react';
export default function IconOnlyDemo() {
/*const sizeOptions = useRef([
{ label: 'Small', value: 'small' },
{ label: 'Normal', value: 'normal' },
{ label: 'Large', value: 'large' }
]);*/
const [size] = useState<'small' | 'normal' | 'large'>('normal');
return (
{/**/}
);
}
```
### Badge
`Badge` component can be used to display a badge inside a button. `Badge.Overlay` is used to display a badge on a button.
```tsx
import { Badge } from 'primereact/badge';
import { Button } from 'primereact/button';
export default function BadgeDemo() {
return (
);
}
```
### Button Group
Multiple buttons are grouped when wrapped inside an element with `Button.Group` component.
```tsx
import { Button } from 'primereact/button';
export default function GroupDemo() {
return (
);
}
```
### Sizes
Button provides `small` and `large` sizes as alternatives to the base.
```tsx
import { Button } from 'primereact/button';
export default function SizeDemo() {
return (
);
}
```
# Button Pass Through
Pass Through documentation for button component
## Viewer
Some sections may not be visible due to the availability of the particular feature.
## Button PT Options
| Label | Type | Description |
|:------|:------|:------|
| root | ButtonPassThroughType> | Used to pass attributes to the root's DOM element. |
## ButtonGroup PT Options
| Label | Type | Description |
|:------|:------|:------|
| root | ButtonGroupPassThroughType> | Used to pass attributes to the root's DOM element. |
# Button Theming
Theming documentation for Button component
## Styled
### Button CSS Classes
List of class names used in the styled mode.
| ClassName | Description |
|:------|:------|
| p-button | Class name of the root element |
| p-button-loading-icon | Class name of the loading icon element |
| p-button-icon | Class name of the icon element |
| p-button-label | Class name of the label element |
### ButtonGroup CSS Classes
List of class names used in the styled mode.
| ClassName | Description |
|:------|:------|
| p-buttongroup | Class name of the root element |
### Design Tokens
List of design tokens.
| Token | CSS Variable | Description |
|:------|:------|:------|
| button.border.radius | --p-button-border-radius | Border radius of root |
| button.rounded.border.radius | --p-button-rounded-border-radius | Rounded border radius of root |
| button.gap | --p-button-gap | Gap of root |
| button.padding.x | --p-button-padding-x | Padding x of root |
| button.padding.y | --p-button-padding-y | Padding y of root |
| button.icon.only.width | --p-button-icon-only-width | Icon only width of root |
| button.sm.font.size | --p-button-sm-font-size | Sm font size of root |
| button.sm.padding.x | --p-button-sm-padding-x | Sm padding x of root |
| button.sm.padding.y | --p-button-sm-padding-y | Sm padding y of root |
| button.sm.icon.only.width | --p-button-sm-icon-only-width | Sm icon only width of root |
| button.lg.font.size | --p-button-lg-font-size | Lg font size of root |
| button.lg.padding.x | --p-button-lg-padding-x | Lg padding x of root |
| button.lg.padding.y | --p-button-lg-padding-y | Lg padding y of root |
| button.lg.icon.only.width | --p-button-lg-icon-only-width | Lg icon only width of root |
| button.label.font.weight | --p-button-label-font-weight | Label font weight of root |
| button.raised.shadow | --p-button-raised-shadow | Raised shadow of root |
| button.focus.ring.width | --p-button-focus-ring-width | Focus ring width of root |
| button.focus.ring.style | --p-button-focus-ring-style | Focus ring style of root |
| button.focus.ring.offset | --p-button-focus-ring-offset | Focus ring offset of root |
| button.badge.size | --p-button-badge-size | Badge size of root |
| button.transition.duration | --p-button-transition-duration | Transition duration of root |
| button.primary.background | --p-button-primary-background | Primary background of root |
| button.primary.hover.background | --p-button-primary-hover-background | Primary hover background of root |
| button.primary.active.background | --p-button-primary-active-background | Primary active background of root |
| button.primary.border.color | --p-button-primary-border-color | Primary border color of root |
| button.primary.hover.border.color | --p-button-primary-hover-border-color | Primary hover border color of root |
| button.primary.active.border.color | --p-button-primary-active-border-color | Primary active border color of root |
| button.primary.color | --p-button-primary-color | Primary color of root |
| button.primary.hover.color | --p-button-primary-hover-color | Primary hover color of root |
| button.primary.active.color | --p-button-primary-active-color | Primary active color of root |
| button.primary.focus.ring.color | --p-button-primary-focus-ring-color | Primary focus ring color of root |
| button.primary.focus.ring.shadow | --p-button-primary-focus-ring-shadow | Primary focus ring shadow of root |
| button.secondary.background | --p-button-secondary-background | Secondary background of root |
| button.secondary.hover.background | --p-button-secondary-hover-background | Secondary hover background of root |
| button.secondary.active.background | --p-button-secondary-active-background | Secondary active background of root |
| button.secondary.border.color | --p-button-secondary-border-color | Secondary border color of root |
| button.secondary.hover.border.color | --p-button-secondary-hover-border-color | Secondary hover border color of root |
| button.secondary.active.border.color | --p-button-secondary-active-border-color | Secondary active border color of root |
| button.secondary.color | --p-button-secondary-color | Secondary color of root |
| button.secondary.hover.color | --p-button-secondary-hover-color | Secondary hover color of root |
| button.secondary.active.color | --p-button-secondary-active-color | Secondary active color of root |
| button.secondary.focus.ring.color | --p-button-secondary-focus-ring-color | Secondary focus ring color of root |
| button.secondary.focus.ring.shadow | --p-button-secondary-focus-ring-shadow | Secondary focus ring shadow of root |
| button.info.background | --p-button-info-background | Info background of root |
| button.info.hover.background | --p-button-info-hover-background | Info hover background of root |
| button.info.active.background | --p-button-info-active-background | Info active background of root |
| button.info.border.color | --p-button-info-border-color | Info border color of root |
| button.info.hover.border.color | --p-button-info-hover-border-color | Info hover border color of root |
| button.info.active.border.color | --p-button-info-active-border-color | Info active border color of root |
| button.info.color | --p-button-info-color | Info color of root |
| button.info.hover.color | --p-button-info-hover-color | Info hover color of root |
| button.info.active.color | --p-button-info-active-color | Info active color of root |
| button.info.focus.ring.color | --p-button-info-focus-ring-color | Info focus ring color of root |
| button.info.focus.ring.shadow | --p-button-info-focus-ring-shadow | Info focus ring shadow of root |
| button.success.background | --p-button-success-background | Success background of root |
| button.success.hover.background | --p-button-success-hover-background | Success hover background of root |
| button.success.active.background | --p-button-success-active-background | Success active background of root |
| button.success.border.color | --p-button-success-border-color | Success border color of root |
| button.success.hover.border.color | --p-button-success-hover-border-color | Success hover border color of root |
| button.success.active.border.color | --p-button-success-active-border-color | Success active border color of root |
| button.success.color | --p-button-success-color | Success color of root |
| button.success.hover.color | --p-button-success-hover-color | Success hover color of root |
| button.success.active.color | --p-button-success-active-color | Success active color of root |
| button.success.focus.ring.color | --p-button-success-focus-ring-color | Success focus ring color of root |
| button.success.focus.ring.shadow | --p-button-success-focus-ring-shadow | Success focus ring shadow of root |
| button.warn.background | --p-button-warn-background | Warn background of root |
| button.warn.hover.background | --p-button-warn-hover-background | Warn hover background of root |
| button.warn.active.background | --p-button-warn-active-background | Warn active background of root |
| button.warn.border.color | --p-button-warn-border-color | Warn border color of root |
| button.warn.hover.border.color | --p-button-warn-hover-border-color | Warn hover border color of root |
| button.warn.active.border.color | --p-button-warn-active-border-color | Warn active border color of root |
| button.warn.color | --p-button-warn-color | Warn color of root |
| button.warn.hover.color | --p-button-warn-hover-color | Warn hover color of root |
| button.warn.active.color | --p-button-warn-active-color | Warn active color of root |
| button.warn.focus.ring.color | --p-button-warn-focus-ring-color | Warn focus ring color of root |
| button.warn.focus.ring.shadow | --p-button-warn-focus-ring-shadow | Warn focus ring shadow of root |
| button.help.background | --p-button-help-background | Help background of root |
| button.help.hover.background | --p-button-help-hover-background | Help hover background of root |
| button.help.active.background | --p-button-help-active-background | Help active background of root |
| button.help.border.color | --p-button-help-border-color | Help border color of root |
| button.help.hover.border.color | --p-button-help-hover-border-color | Help hover border color of root |
| button.help.active.border.color | --p-button-help-active-border-color | Help active border color of root |
| button.help.color | --p-button-help-color | Help color of root |
| button.help.hover.color | --p-button-help-hover-color | Help hover color of root |
| button.help.active.color | --p-button-help-active-color | Help active color of root |
| button.help.focus.ring.color | --p-button-help-focus-ring-color | Help focus ring color of root |
| button.help.focus.ring.shadow | --p-button-help-focus-ring-shadow | Help focus ring shadow of root |
| button.danger.background | --p-button-danger-background | Danger background of root |
| button.danger.hover.background | --p-button-danger-hover-background | Danger hover background of root |
| button.danger.active.background | --p-button-danger-active-background | Danger active background of root |
| button.danger.border.color | --p-button-danger-border-color | Danger border color of root |
| button.danger.hover.border.color | --p-button-danger-hover-border-color | Danger hover border color of root |
| button.danger.active.border.color | --p-button-danger-active-border-color | Danger active border color of root |
| button.danger.color | --p-button-danger-color | Danger color of root |
| button.danger.hover.color | --p-button-danger-hover-color | Danger hover color of root |
| button.danger.active.color | --p-button-danger-active-color | Danger active color of root |
| button.danger.focus.ring.color | --p-button-danger-focus-ring-color | Danger focus ring color of root |
| button.danger.focus.ring.shadow | --p-button-danger-focus-ring-shadow | Danger focus ring shadow of root |
| button.contrast.background | --p-button-contrast-background | Contrast background of root |
| button.contrast.hover.background | --p-button-contrast-hover-background | Contrast hover background of root |
| button.contrast.active.background | --p-button-contrast-active-background | Contrast active background of root |
| button.contrast.border.color | --p-button-contrast-border-color | Contrast border color of root |
| button.contrast.hover.border.color | --p-button-contrast-hover-border-color | Contrast hover border color of root |
| button.contrast.active.border.color | --p-button-contrast-active-border-color | Contrast active border color of root |
| button.contrast.color | --p-button-contrast-color | Contrast color of root |
| button.contrast.hover.color | --p-button-contrast-hover-color | Contrast hover color of root |
| button.contrast.active.color | --p-button-contrast-active-color | Contrast active color of root |
| button.contrast.focus.ring.color | --p-button-contrast-focus-ring-color | Contrast focus ring color of root |
| button.contrast.focus.ring.shadow | --p-button-contrast-focus-ring-shadow | Contrast focus ring shadow of root |
| button.outlined.primary.hover.background | --p-button-outlined-primary-hover-background | Primary hover background of outlined |
| button.outlined.primary.active.background | --p-button-outlined-primary-active-background | Primary active background of outlined |
| button.outlined.primary.border.color | --p-button-outlined-primary-border-color | Primary border color of outlined |
| button.outlined.primary.color | --p-button-outlined-primary-color | Primary color of outlined |
| button.outlined.secondary.hover.background | --p-button-outlined-secondary-hover-background | Secondary hover background of outlined |
| button.outlined.secondary.active.background | --p-button-outlined-secondary-active-background | Secondary active background of outlined |
| button.outlined.secondary.border.color | --p-button-outlined-secondary-border-color | Secondary border color of outlined |
| button.outlined.secondary.color | --p-button-outlined-secondary-color | Secondary color of outlined |
| button.outlined.success.hover.background | --p-button-outlined-success-hover-background | Success hover background of outlined |
| button.outlined.success.active.background | --p-button-outlined-success-active-background | Success active background of outlined |
| button.outlined.success.border.color | --p-button-outlined-success-border-color | Success border color of outlined |
| button.outlined.success.color | --p-button-outlined-success-color | Success color of outlined |
| button.outlined.info.hover.background | --p-button-outlined-info-hover-background | Info hover background of outlined |
| button.outlined.info.active.background | --p-button-outlined-info-active-background | Info active background of outlined |
| button.outlined.info.border.color | --p-button-outlined-info-border-color | Info border color of outlined |
| button.outlined.info.color | --p-button-outlined-info-color | Info color of outlined |
| button.outlined.warn.hover.background | --p-button-outlined-warn-hover-background | Warn hover background of outlined |
| button.outlined.warn.active.background | --p-button-outlined-warn-active-background | Warn active background of outlined |
| button.outlined.warn.border.color | --p-button-outlined-warn-border-color | Warn border color of outlined |
| button.outlined.warn.color | --p-button-outlined-warn-color | Warn color of outlined |
| button.outlined.help.hover.background | --p-button-outlined-help-hover-background | Help hover background of outlined |
| button.outlined.help.active.background | --p-button-outlined-help-active-background | Help active background of outlined |
| button.outlined.help.border.color | --p-button-outlined-help-border-color | Help border color of outlined |
| button.outlined.help.color | --p-button-outlined-help-color | Help color of outlined |
| button.outlined.danger.hover.background | --p-button-outlined-danger-hover-background | Danger hover background of outlined |
| button.outlined.danger.active.background | --p-button-outlined-danger-active-background | Danger active background of outlined |
| button.outlined.danger.border.color | --p-button-outlined-danger-border-color | Danger border color of outlined |
| button.outlined.danger.color | --p-button-outlined-danger-color | Danger color of outlined |
| button.outlined.contrast.hover.background | --p-button-outlined-contrast-hover-background | Contrast hover background of outlined |
| button.outlined.contrast.active.background | --p-button-outlined-contrast-active-background | Contrast active background of outlined |
| button.outlined.contrast.border.color | --p-button-outlined-contrast-border-color | Contrast border color of outlined |
| button.outlined.contrast.color | --p-button-outlined-contrast-color | Contrast color of outlined |
| button.outlined.plain.hover.background | --p-button-outlined-plain-hover-background | Plain hover background of outlined |
| button.outlined.plain.active.background | --p-button-outlined-plain-active-background | Plain active background of outlined |
| button.outlined.plain.border.color | --p-button-outlined-plain-border-color | Plain border color of outlined |
| button.outlined.plain.color | --p-button-outlined-plain-color | Plain color of outlined |
| button.text.primary.hover.background | --p-button-text-primary-hover-background | Primary hover background of text |
| button.text.primary.active.background | --p-button-text-primary-active-background | Primary active background of text |
| button.text.primary.color | --p-button-text-primary-color | Primary color of text |
| button.text.secondary.hover.background | --p-button-text-secondary-hover-background | Secondary hover background of text |
| button.text.secondary.active.background | --p-button-text-secondary-active-background | Secondary active background of text |
| button.text.secondary.color | --p-button-text-secondary-color | Secondary color of text |
| button.text.success.hover.background | --p-button-text-success-hover-background | Success hover background of text |
| button.text.success.active.background | --p-button-text-success-active-background | Success active background of text |
| button.text.success.color | --p-button-text-success-color | Success color of text |
| button.text.info.hover.background | --p-button-text-info-hover-background | Info hover background of text |
| button.text.info.active.background | --p-button-text-info-active-background | Info active background of text |
| button.text.info.color | --p-button-text-info-color | Info color of text |
| button.text.warn.hover.background | --p-button-text-warn-hover-background | Warn hover background of text |
| button.text.warn.active.background | --p-button-text-warn-active-background | Warn active background of text |
| button.text.warn.color | --p-button-text-warn-color | Warn color of text |
| button.text.help.hover.background | --p-button-text-help-hover-background | Help hover background of text |
| button.text.help.active.background | --p-button-text-help-active-background | Help active background of text |
| button.text.help.color | --p-button-text-help-color | Help color of text |
| button.text.danger.hover.background | --p-button-text-danger-hover-background | Danger hover background of text |
| button.text.danger.active.background | --p-button-text-danger-active-background | Danger active background of text |
| button.text.danger.color | --p-button-text-danger-color | Danger color of text |
| button.text.contrast.hover.background | --p-button-text-contrast-hover-background | Contrast hover background of text |
| button.text.contrast.active.background | --p-button-text-contrast-active-background | Contrast active background of text |
| button.text.contrast.color | --p-button-text-contrast-color | Contrast color of text |
| button.text.plain.hover.background | --p-button-text-plain-hover-background | Plain hover background of text |
| button.text.plain.active.background | --p-button-text-plain-active-background | Plain active background of text |
| button.text.plain.color | --p-button-text-plain-color | Plain color of text |
| button.link.color | --p-button-link-color | Color of link |
| button.link.hover.color | --p-button-link-hover-color | Hover color of link |
| button.link.active.color | --p-button-link-active-color | Active color of link |
## Unstyled
Theming is implemented with the pass through properties in unstyled mode.
# Card
Card is a flexible container component.
## Usage
```tsx
import { Card } from 'primereact/card';
```
```tsx
```
## Examples
### With Form
Use `Card`, `Card.Body`, `Card.Caption`, `Card.Title`, `Card.Subtitle`, `Card.Content`, `Card.Footer`, to create a simple card.
```tsx
import Link from 'next/link';
import { Button } from 'primereact/button';
import { Card } from 'primereact/card';
import { InputText } from 'primereact/inputtext';
import { Label } from 'primereact/label';
export default function BasicDemo() {
return (
Welcome backSign in with your email to continue.
Don’t have an account?{' '}
);
}
```
### Advanced
Use `Card.Header` to place an image, avatar or other content in the header.
```tsx
import { Avatar } from 'primereact/avatar';
import { Button } from 'primereact/button';
import { Card } from 'primereact/card';
import { Tag } from 'primereact/tag';
export default function AdvancedDemo() {
return (
Sakura Fresh Market
Daily
Premium
Sakura Fresh Market is your go-to store for fresh local produce, Japanese snacks, and daily essentials — all in one place!
4.6 (200+ reviews)
Tokyo, Shibuya-ku
);
}
```
# Checkbox API
API documentation for Checkbox component
## Checkbox
### Props
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| ref | Ref | null | The reference to the component instance. |
| pIf | boolean | true | Whether the component should be rendered. |
| style | CSSProperties \\| ((instance?: CheckboxInstance) => CSSProperties) | null | The style to apply to the component. |
| className | string \\| ((instance?: CheckboxInstance) => string) | null | The class name to apply to the component. |
| as | string \\| number \\| bigint \\| boolean \\| ComponentClass \\| FunctionComponent \\| ReactElement> \\| Iterable \\| ReactPortal \\| Promise | null | The component type to render. |
| asChild | boolean | false | Whether the component should be rendered as a child component. |
| pt | SafeRecord | null | The pass-through props to pass to the component |
| ptOptions | PassThroughOptions | null | The pass-through options to pass to the component |
| unstyled | boolean | null | Whether the component should be rendered without classes. |
| dt | unknown | null | The design token to use for the component. |
| styles | StylesOptions | null | The styles to use for the component. |
| children | ReactNode \\| ((instance: CheckboxInstance) => ReactNode) | null | The children to render. |
| value | unknown | null | Value of the checkbox. |
| name | string | null | The name of the checkbox. |
| size | "small" \\| "large" \\| "normal" | null | Defines the size of the checkbox. |
| variant | "outlined" \\| "filled" | null | Specifies the input variant of the component. |
| disabled | boolean | false | When present, it specifies that the element should be disabled. |
| readOnly | boolean | false | When present, it specifies that an input field is read-only. |
| required | boolean | false | When present, it specifies that the element is required. |
| invalid | boolean | false | When present, it specifies that the component should have invalid state style. |
| inputId | string | null | Identifier of the underlying input element. |
| inputStyle | CSSProperties | null | Inline style of the input field. |
| inputClassName | string | null | Style class of the input field. |
| ariaLabel | string | null | Establishes a string value that labels the component. |
| ariaLabelledby | string | null | Establishes relationships between the component and label(s) where its value should be one or more element IDs. |
| onFocus | (event: FocusEvent) => void | null | Callback function that is called when the checkbox is focused. |
| onBlur | (event: FocusEvent) => void | null | Callback function that is called when the checkbox loses focus. |
| onCheckedChange | (event: CheckboxChangeEvent) => void | null | Callback fired when the checkbox's checked state changes. |
| checked | boolean | null | When present, it specifies the input's checked state. |
| defaultChecked | boolean | null | The default value for the input when not controlled by `checked` and `onCheckedChange` . |
| indeterminate | boolean | false | When present, it specifies input state as indeterminate. |
| trueValue | string \\| number \\| boolean | true | Value in checked state. |
| falseValue | string \\| number \\| boolean | false | Value in unchecked state. |
| [key: string] | any | null | |
| pt-{optionName}-* | - | null | Pass through attributes for customizing component. For more info, see Pass Through tab. |
### State
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| checked | boolean | null | The checked state of the useCheckbox. |
| indeterminate | boolean | null | The indeterminate state of the useCheckbox. |
### Exposes
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| group | CheckboxGroupInstance | null | The group instance of the checkbox. |
| state | useCheckboxState | null | The state of the useCheckbox. |
| onChange | (event: useCheckboxChangeEvent) => void | null | Callback fired when the useCheckbox's checked state changes. |
### Events
| Id | Label | Description | RelatedProp | Data |
|:------|:------|:------|:------|:------|
| api.checkbox.events.CheckboxChangeEvent | CheckboxChangeEvent | Event fired when the checkbox's checked state changes. | | [object Object],[object Object],[object Object] |
### Interfaces
| Label | Description | Data |
|:------|:------|:------|
| PassThroughOptions | Defines passthrough(pt) options of Checkbox component. | [object Object],[object Object],[object Object],[object Object] |
### Types
| Label | Description | Data |
|:------|:------|:------|
| Instance | Instance of Checkbox component. | [object Object] |
## CheckboxGroup
### Props
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| ref | Ref | null | The reference to the component instance. |
| pIf | boolean | true | Whether the component should be rendered. |
| style | CSSProperties \\| ((instance?: CheckboxGroupInstance) => CSSProperties) | null | The style to apply to the component. |
| className | string \\| ((instance?: CheckboxGroupInstance) => string) | null | The class name to apply to the component. |
| as | string \\| number \\| bigint \\| boolean \\| ComponentClass \\| FunctionComponent \\| ReactElement> \\| Iterable \\| ReactPortal \\| Promise | null | The component type to render. |
| asChild | boolean | false | Whether the component should be rendered as a child component. |
| pt | SafeRecord | null | The pass-through props to pass to the component |
| ptOptions | PassThroughOptions | null | The pass-through options to pass to the component |
| unstyled | boolean | null | Whether the component should be rendered without classes. |
| dt | unknown | null | The design token to use for the component. |
| styles | StylesOptions | null | The styles to use for the component. |
| children | ReactNode \\| ((instance: CheckboxGroupInstance) => ReactNode) | null | The children to render. |
| value | unknown[] | null | Value of the checkbox group. |
| defaultValue | unknown[] | null | The default value of the checkbox group. |
| name | string | null | The name of the checkboxes. |
| disabled | boolean | false | When present, it specifies that the checkbox group should be disabled. |
| invalid | boolean | false | When present, it specifies that the checkbox group is invalid. |
| onValueChange | (event: CheckboxGroupValueChangeEvent) => void | null | Callback function that is called when the checkbox group value changes. |
| [key: string] | any | null | |
| pt-{optionName}-* | - | null | Pass through attributes for customizing component. For more info, see Pass Through tab. |
### State
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| value | unknown[] | null | Value of the checkbox group. |
### Exposes
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| state | CheckboxGroupState | null | The state of the checkbox group. |
| updateChange | (event: CheckboxGroupUpdateChangeEvent) => void | null | Updates the value of the checkbox group. |
### Events
| Id | Label | Description | RelatedProp | Data |
|:------|:------|:------|:------|:------|
| api.checkboxgroup.events.CheckboxGroupValueChangeEvent | CheckboxGroupValueChangeEvent | Event fired when the checkbox group's value changes. | | [object Object] |
| api.checkboxgroup.events.CheckboxGroupUpdateChangeEvent | CheckboxGroupUpdateChangeEvent | Used to update the checkbox group value. | | [object Object],[object Object],[object Object] |
### Interfaces
| Label | Description | Data |
|:------|:------|:------|
| PassThroughOptions | Defines passthrough(pt) options of Checkbox component. | [object Object] |
### Types
| Label | Description | Data |
|:------|:------|:------|
| Instance | Instance of CheckboxGroup component. | [object Object] |
## useCheckbox
### Props
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| checked | boolean | null | When present, it specifies the input's checked state. |
| defaultChecked | boolean | null | The default value for the input when not controlled by `checked` and `onCheckedChange` . |
| indeterminate | boolean | false | When present, it specifies input state as indeterminate. |
| trueValue | string \\| number \\| boolean | true | Value in checked state. |
| falseValue | string \\| number \\| boolean | false | Value in unchecked state. |
| onCheckedChange | (event: useCheckboxChangeEvent) => void | null | Callback fired when the checkbox's checked state changes. |
### State
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| checked | boolean | null | The checked state of the useCheckbox. |
| indeterminate | boolean | null | The indeterminate state of the useCheckbox. |
### Exposes
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| state | useCheckboxState | null | The state of the useCheckbox. |
| onChange | (event: useCheckboxChangeEvent) => void | null | Callback fired when the useCheckbox's checked state changes. |
### Events
| Id | Label | Description | RelatedProp | Data |
|:------|:------|:------|:------|:------|
| api.usecheckbox.events.useCheckboxChangeEvent | useCheckboxChangeEvent | Event fired when the checkbox's checked state changes. | | [object Object],[object Object] |
### Types
| Label | Description | Data |
|:------|:------|:------|
| Instance | Instance of useCheckbox headless. | [object Object] |
# Checkbox
Checkbox is an extension to standard checkbox element with theming.
## Usage
```tsx
import { Checkbox } from 'primereact/checkbox';
```
```tsx
```
## Examples
### Basic
```tsx
import { Checkbox } from 'primereact/checkbox';
const BasicDemo = () => {
return (
);
};
export default BasicDemo;
```
### Group
Use the `Checkbox.Group` component with `value` and `onValueChange` props to control the selected state of checkboxes.
```tsx
'use client';
import type { CheckboxGroupValueChangeEvent } from '@primereact/types/shared/checkbox';
import { Checkbox } from 'primereact/checkbox';
import React from 'react';
export default function GroupDemo() {
const [value, setValue] = React.useState();
return (
setValue(e.value as string[])} className="gap-4 flex-wrap">
);
}
```
### Dynamic
Checkboxes can be generated using a list of values.
```tsx
'use client';
import type { CheckboxGroupValueChangeEvent } from '@primereact/types/shared/checkbox';
import { Checkbox } from 'primereact/checkbox';
import React from 'react';
export default function DynamicDemo() {
const [value, setValue] = React.useState([]);
const categories = [
{ name: 'Accounting', key: 'A' },
{ name: 'Marketing', key: 'M' },
{ name: 'Production', key: 'P' },
{ name: 'Research', key: 'R' }
];
return (
setValue(e.value as string[])} className="flex-col gap-4">
{categories.map((category) => (
))}
);
}
```
### Card
Checkboxes can be displayed in a card format.
```tsx
'use client';
import type { CheckboxGroupValueChangeEvent } from '@primereact/types/shared/checkbox';
import { Checkbox } from 'primereact/checkbox';
import React from 'react';
const interests = [
{
id: 'tech',
title: '💻 Technology',
description: 'Latest updates in software, gadgets, and innovation.'
},
{
id: 'design',
title: '🎨 Design',
description: 'UI/UX trends, graphic design tips, and creativity.'
},
{
id: 'finance',
title: '💰 Finance',
description: 'Investing, saving, and crypto news.'
}
];
export default function CardDemo() {
const [value, setValue] = React.useState([]);
return (
setValue(e.value as string[])} className="flex-col gap-4 pl-7">
{categories.map((item) => (
))}
);
}
```
### Sizes
Use the `size` property to change the size of a checkbox.
```tsx
import { Checkbox } from 'primereact/checkbox';
export default function SizesDemo() {
return (
);
}
```
### Filled
Specify the `filled` property to display the component with a higher visual emphasis than the default outlined style.
```tsx
import { Checkbox } from 'primereact/checkbox';
export default function FilledDemo() {
return (
);
}
```
### Disabled
Use the `disabled` property to disable a checkbox.
```tsx
import { Checkbox } from 'primereact/checkbox';
export default function DisabledDemo() {
return (
);
}
```
### Invalid
Specify the `invalid` property to display the component with a red border.
```tsx
import { Checkbox } from 'primereact/checkbox';
export default function InvalidDemo() {
return (
);
}
```
# Checkbox Pass Through
Pass Through documentation for Checkbox component
## Viewer
Some sections may not be visible due to the availability of the particular feature. Section names that start with the pc prefix indicate that the element is a PrimeReact component not a DOM element.
## Checkbox PT Options
| Label | Type | Description |
|:------|:------|:------|
| root | CheckboxPassThroughType> | Used to pass attributes to the root's DOM element. |
| input | CheckboxPassThroughType> | Used to pass attributes to the input's DOM element. |
| box | CheckboxPassThroughType> | Used to pass attributes to the box's DOM element. |
| icon | CheckboxPassThroughType> | Used to pass attributes to the icon's DOM element. |
## CheckboxGroup PT Options
| Label | Type | Description |
|:------|:------|:------|
| root | CheckboxGroupPassThroughType> | Used to pass attributes to the root's DOM element. |
# Checkbox Theming
Theming documentation for Checkbox component
## Styled
### Checkbox CSS Classes
List of class names used in the styled mode.
| ClassName | Description |
|:------|:------|
| p-checkbox | Class name of the root element |
| p-checkbox-box | Class name of the box element |
| p-checkbox-input | Class name of the input element |
| p-checkbox-icon | Class name of the icon element |
### CheckboxGroup CSS Classes
List of class names used in the styled mode.
| ClassName | Description |
|:------|:------|
| p-checkbox-group | Class name of the root element |
### Design Tokens
List of design tokens.
| Token | CSS Variable | Description |
|:------|:------|:------|
| checkbox.border.radius | --p-checkbox-border-radius | Border radius of root |
| checkbox.width | --p-checkbox-width | Width of root |
| checkbox.height | --p-checkbox-height | Height of root |
| checkbox.background | --p-checkbox-background | Background of root |
| checkbox.checked.background | --p-checkbox-checked-background | Checked background of root |
| checkbox.checked.hover.background | --p-checkbox-checked-hover-background | Checked hover background of root |
| checkbox.disabled.background | --p-checkbox-disabled-background | Disabled background of root |
| checkbox.filled.background | --p-checkbox-filled-background | Filled background of root |
| checkbox.border.color | --p-checkbox-border-color | Border color of root |
| checkbox.hover.border.color | --p-checkbox-hover-border-color | Hover border color of root |
| checkbox.focus.border.color | --p-checkbox-focus-border-color | Focus border color of root |
| checkbox.checked.border.color | --p-checkbox-checked-border-color | Checked border color of root |
| checkbox.checked.hover.border.color | --p-checkbox-checked-hover-border-color | Checked hover border color of root |
| checkbox.checked.focus.border.color | --p-checkbox-checked-focus-border-color | Checked focus border color of root |
| checkbox.checked.disabled.border.color | --p-checkbox-checked-disabled-border-color | Checked disabled border color of root |
| checkbox.invalid.border.color | --p-checkbox-invalid-border-color | Invalid border color of root |
| checkbox.shadow | --p-checkbox-shadow | Shadow of root |
| checkbox.focus.ring.width | --p-checkbox-focus-ring-width | Focus ring width of root |
| checkbox.focus.ring.style | --p-checkbox-focus-ring-style | Focus ring style of root |
| checkbox.focus.ring.color | --p-checkbox-focus-ring-color | Focus ring color of root |
| checkbox.focus.ring.offset | --p-checkbox-focus-ring-offset | Focus ring offset of root |
| checkbox.focus.ring.shadow | --p-checkbox-focus-ring-shadow | Focus ring shadow of root |
| checkbox.transition.duration | --p-checkbox-transition-duration | Transition duration of root |
| checkbox.sm.width | --p-checkbox-sm-width | Sm width of root |
| checkbox.sm.height | --p-checkbox-sm-height | Sm height of root |
| checkbox.lg.width | --p-checkbox-lg-width | Lg width of root |
| checkbox.lg.height | --p-checkbox-lg-height | Lg height of root |
| checkbox.icon.size | --p-checkbox-icon-size | Size of icon |
| checkbox.icon.color | --p-checkbox-icon-color | Color of icon |
| checkbox.icon.checked.color | --p-checkbox-icon-checked-color | Checked color of icon |
| checkbox.icon.checked.hover.color | --p-checkbox-icon-checked-hover-color | Checked hover color of icon |
| checkbox.icon.disabled.color | --p-checkbox-icon-disabled-color | Disabled color of icon |
| checkbox.icon.sm.size | --p-checkbox-icon-sm-size | Sm size of icon |
| checkbox.icon.lg.size | --p-checkbox-icon-lg-size | Lg size of icon |
## Unstyled
Theming is implemented with the pass through properties in unstyled mode.
# Chip API
API documentation for Chip component
## Chip
### Props
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| ref | Ref | null | The reference to the component instance. |
| pIf | boolean | true | Whether the component should be rendered. |
| style | CSSProperties \\| ((instance?: ChipInstance) => CSSProperties) | null | The style to apply to the component. |
| className | string \\| ((instance?: ChipInstance) => string) | null | The class name to apply to the component. |
| as | string \\| number \\| bigint \\| boolean \\| ComponentClass \\| FunctionComponent \\| ReactElement> \\| Iterable \\| ReactPortal \\| Promise | null | The component type to render. |
| asChild | boolean | false | Whether the component should be rendered as a child component. |
| pt | SafeRecord | null | The pass-through props to pass to the component |
| ptOptions | PassThroughOptions | null | The pass-through options to pass to the component |
| unstyled | boolean | null | Whether the component should be rendered without classes. |
| dt | unknown | null | The design token to use for the component. |
| styles | StylesOptions | null | The styles to use for the component. |
| children | ReactNode \\| ((instance: ChipInstance) => ReactNode) | null | The children to render. |
| onRemove | (event: useChipRemoveEvent) => void | null | Callback fired when the chip is removed. |
| [key: string] | any | null | |
| pt-{optionName}-* | - | null | Pass through attributes for customizing component. For more info, see Pass Through tab. |
### State
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| visible | boolean | null | The visibility state of the chip. |
### Exposes
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| state | useChipState | null | The state of the useChip. |
| close | (event: SyntheticEvent) => void | null | Closes the chip. |
| removeIconProps | { onKeyDown: (event: KeyboardEvent) => void } | null | Props for the remove icon. |
### Interfaces
| Label | Description | Data |
|:------|:------|:------|
| PassThroughOptions | Defines passthrough(pt) options of Chip component. | [object Object],[object Object],[object Object],[object Object],[object Object] |
### Types
| Label | Description | Data |
|:------|:------|:------|
| Instance | Instance of Chip component. | [object Object] |
## ChipIcon
### Props
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| ref | Ref | null | The reference to the component instance. |
| pIf | boolean | true | Whether the component should be rendered. |
| style | CSSProperties \\| ((instance?: ChipIconInstance) => CSSProperties) | null | The style to apply to the component. |
| className | string \\| ((instance?: ChipIconInstance) => string) | null | The class name to apply to the component. |
| as | string \\| number \\| bigint \\| boolean \\| ComponentClass \\| FunctionComponent \\| ReactElement> \\| Iterable \\| ReactPortal \\| Promise | null | The component type to render. |
| asChild | boolean | false | Whether the component should be rendered as a child component. |
| pt | SafeRecord | null | The pass-through props to pass to the component |
| ptOptions | PassThroughOptions | null | The pass-through options to pass to the component |
| unstyled | boolean | null | Whether the component should be rendered without classes. |
| dt | unknown | null | The design token to use for the component. |
| styles | StylesOptions | null | The styles to use for the component. |
| children | ReactNode \\| ((instance: ChipIconInstance) => ReactNode) | null | The children to render. |
| [key: string] | any | null | |
| pt-{optionName}-* | - | null | Pass through attributes for customizing component. For more info, see Pass Through tab. |
### State
### Exposes
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| chip | ChipInstance | null | The Chip component instance. |
### Interfaces
| Label | Description | Data |
|:------|:------|:------|
| PassThroughOptions | Defines passthrough(pt) options of ChipIcon component. | [object Object] |
### Types
| Label | Description | Data |
|:------|:------|:------|
| Instance | Instance of ChipIcon component. | [object Object] |
## ChipLabel
### Props
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| ref | Ref | null | The reference to the component instance. |
| pIf | boolean | true | Whether the component should be rendered. |
| style | CSSProperties \\| ((instance?: ChipLabelInstance) => CSSProperties) | null | The style to apply to the component. |
| className | string \\| ((instance?: ChipLabelInstance) => string) | null | The class name to apply to the component. |
| as | string \\| number \\| bigint \\| boolean \\| ComponentClass \\| FunctionComponent \\| ReactElement> \\| Iterable \\| ReactPortal \\| Promise | null | The component type to render. |
| asChild | boolean | false | Whether the component should be rendered as a child component. |
| pt | SafeRecord | null | The pass-through props to pass to the component |
| ptOptions | PassThroughOptions | null | The pass-through options to pass to the component |
| unstyled | boolean | null | Whether the component should be rendered without classes. |
| dt | unknown | null | The design token to use for the component. |
| styles | StylesOptions | null | The styles to use for the component. |
| children | ReactNode \\| ((instance: ChipLabelInstance) => ReactNode) | null | The children to render. |
| [key: string] | any | null | |
| pt-{optionName}-* | - | null | Pass through attributes for customizing component. For more info, see Pass Through tab. |
### Exposes
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| chip | ChipInstance | null | The Chip component instance. |
### Interfaces
| Label | Description | Data |
|:------|:------|:------|
| PassThroughOptions | Defines passthrough(pt) options of ChipLabel component. | [object Object] |
### Types
| Label | Description | Data |
|:------|:------|:------|
| Instance | Instance of ChipLabel component. | [object Object] |
## ChipImage
### Props
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| ref | Ref | null | The reference to the component instance. |
| pIf | boolean | true | Whether the component should be rendered. |
| style | CSSProperties \\| ((instance?: ChipImageInstance) => CSSProperties) | null | The style to apply to the component. |
| className | string \\| ((instance?: ChipImageInstance) => string) | null | The class name to apply to the component. |
| as | string \\| number \\| bigint \\| boolean \\| ComponentClass \\| FunctionComponent \\| ReactElement> \\| Iterable \\| ReactPortal \\| Promise | null | The component type to render. |
| asChild | boolean | false | Whether the component should be rendered as a child component. |
| pt | SafeRecord | null | The pass-through props to pass to the component |
| ptOptions | PassThroughOptions | null | The pass-through options to pass to the component |
| unstyled | boolean | null | Whether the component should be rendered without classes. |
| dt | unknown | null | The design token to use for the component. |
| styles | StylesOptions | null | The styles to use for the component. |
| children | ReactNode \\| ((instance: ChipImageInstance) => ReactNode) | null | The children to render. |
| [key: string] | any | null | |
| pt-{optionName}-* | - | null | Pass through attributes for customizing component. For more info, see Pass Through tab. |
### Exposes
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| chip | ChipInstance | null | The Chip component instance. |
### Interfaces
| Label | Description | Data |
|:------|:------|:------|
| PassThroughOptions | Defines passthrough(pt) options of ChipImage component. | [object Object] |
### Types
| Label | Description | Data |
|:------|:------|:------|
| Instance | Instance of ChipImage component. | [object Object] |
## ChipRemoveIcon
### Props
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| ref | Ref | null | The reference to the component instance. |
| pIf | boolean | true | Whether the component should be rendered. |
| style | CSSProperties \\| ((instance?: ChipRemoveIconInstance) => CSSProperties) | null | The style to apply to the component. |
| className | string \\| ((instance?: ChipRemoveIconInstance) => string) | null | The class name to apply to the component. |
| as | string \\| number \\| bigint \\| boolean \\| ComponentClass \\| FunctionComponent \\| ReactElement> \\| Iterable \\| ReactPortal \\| Promise | null | The component type to render. |
| asChild | boolean | false | Whether the component should be rendered as a child component. |
| pt | SafeRecord | null | The pass-through props to pass to the component |
| ptOptions | PassThroughOptions | null | The pass-through options to pass to the component |
| unstyled | boolean | null | Whether the component should be rendered without classes. |
| dt | unknown | null | The design token to use for the component. |
| styles | StylesOptions | null | The styles to use for the component. |
| children | ReactNode \\| ((instance: ChipRemoveIconInstance) => ReactNode) | null | The children to render. |
| [key: string] | any | null | |
| pt-{optionName}-* | - | null | Pass through attributes for customizing component. For more info, see Pass Through tab. |
### Exposes
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| chip | ChipInstance | null | The Chip component instance. |
### Interfaces
| Label | Description | Data |
|:------|:------|:------|
| PassThroughOptions | Defines passthrough(pt) options of ChipRemoveIcon component. | [object Object] |
### Types
| Label | Description | Data |
|:------|:------|:------|
| Instance | Instance of ChipRemoveIcon component. | [object Object] |
## useChip
### Props
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| onRemove | (event: useChipRemoveEvent) => void | null | Callback fired when the chip is removed. |
### State
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| visible | boolean | null | The visibility state of the chip. |
### Exposes
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| state | useChipState | null | The state of the useChip. |
| close | (event: SyntheticEvent) => void | null | Closes the chip. |
| removeIconProps | { onKeyDown: (event: KeyboardEvent) => void } | null | Props for the remove icon. |
### Events
| Id | Label | Description | RelatedProp | Data |
|:------|:------|:------|:------|:------|
| api.usechip.events.useChipRemoveEvent | useChipRemoveEvent | Event fired when the chip's remove icon is clicked. | | [object Object] |
### Types
| Label | Description | Data |
|:------|:------|:------|
| Instance | Instance of useChip headless. | [object Object] |
# Chip
Chip represents entities using icons, labels and images.
## Usage
```tsx
import { Chip } from 'primereact/chip';
```
```tsx
Chip
```
## Examples
### Basic
A basic chip with a text is created with the _Chip.Label_ component. In addition when Chip.RemoveIcon is added, a delete icon is displayed to remove a chip.
```tsx
import { Chip } from 'primereact/chip';
export default function BasicDemo() {
return (
ActionComedyMysteryThriller
);
}
```
### Icon
A font icon next to the label can be displayed with the _className_ property.
```tsx
import { Chip } from 'primereact/chip';
export default function IconDemo() {
return (
AppleFacebookGoogleMicrosoftGitHub
);
}
```
### Image
The _Chip.Image_ is used to display an image like an avatar.
```tsx
import { Chip } from 'primereact/chip';
export default function ImageDemo() {
return (
Amy ElsnerAsiya JavayantOnyama LimbaXuxue Feng
);
}
```
### Template
Chip also allows displaying custom content inside a itself.
```tsx
import { Chip } from 'primereact/chip';
export default function TemplateDemo() {
return (
PPRIME
);
}
```
## Accessibility
### Screen Reader
Chip uses the `label` property as the default `aria-label`. Any attribute passed to the root element like `aria-labelledby` or `aria-label` can be used to override the default behavior. Removable chips are focusable with the tab key.
### Keyboard Support
| Key | Function |
| --------- | -------------------- |
| backspace | Hides removable chip |
| enter | Hides removable chip |
# Chip Pass Through
Pass Through documentation for Chip component
## Viewer
Some sections may not be visible due to the availability of the particular feature.
## Chip PT Options
| Label | Type | Description |
|:------|:------|:------|
| root | ChipPassThroughType> | Used to pass attributes to the root's DOM element. |
| icon | ChipPassThroughType> | Used to pass attributes to the icon's DOM element. |
| image | ChipPassThroughType> | Used to pass attributes to the image's DOM element. |
| label | ChipPassThroughType> | Used to pass attributes to the label's DOM element. |
| removeIcon | ChipPassThroughType> | Used to pass attributes to the remove icon's DOM element. |
# Chip Theming
Theming documentation for chip component
## Styled
### CSS Classes
List of class names used in the styled mode.
| ClassName | Description |
|:------|:------|
| p-chip | Class name of the root element |
| p-chip-image | Class name of the image element |
| p-chip-icon | Class name of the icon element |
| p-chip-label | Class name of the label element |
| p-chip-remove-icon | Class name of the remove icon element |
### Design Tokens
List of design tokens.
| Token | CSS Variable | Description |
|:------|:------|:------|
| chip.border.radius | --p-chip-border-radius | Border radius of root |
| chip.padding.x | --p-chip-padding-x | Padding x of root |
| chip.padding.y | --p-chip-padding-y | Padding y of root |
| chip.gap | --p-chip-gap | Gap of root |
| chip.transition.duration | --p-chip-transition-duration | Transition duration of root |
| chip.background | --p-chip-background | Background of root |
| chip.color | --p-chip-color | Color of root |
| chip.image.width | --p-chip-image-width | Width of image |
| chip.image.height | --p-chip-image-height | Height of image |
| chip.icon.size | --p-chip-icon-size | Size of icon |
| chip.icon.color | --p-chip-icon-color | Color of icon |
| chip.remove.icon.size | --p-chip-remove-icon-size | Size of remove icon |
| chip.remove.icon.focus.ring.width | --p-chip-remove-icon-focus-ring-width | Focus ring width of remove icon |
| chip.remove.icon.focus.ring.style | --p-chip-remove-icon-focus-ring-style | Focus ring style of remove icon |
| chip.remove.icon.focus.ring.color | --p-chip-remove-icon-focus-ring-color | Focus ring color of remove icon |
| chip.remove.icon.focus.ring.offset | --p-chip-remove-icon-focus-ring-offset | Focus ring offset of remove icon |
| chip.remove.icon.focus.ring.shadow | --p-chip-remove-icon-focus-ring-shadow | Focus ring shadow of remove icon |
| chip.remove.icon.color | --p-chip-remove-icon-color | Color of remove icon |
## Unstyled
Theming is implemented with the pass through properties in unstyled mode.
# Divider API
API documentation for Divider component
## Divider
### Props
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| ref | Ref | null | The reference to the component instance. |
| pIf | boolean | true | Whether the component should be rendered. |
| style | CSSProperties \\| ((instance?: DividerInstance) => CSSProperties) | null | The style to apply to the component. |
| className | string \\| ((instance?: DividerInstance) => string) | null | The class name to apply to the component. |
| as | string \\| number \\| bigint \\| boolean \\| ComponentClass \\| FunctionComponent \\| ReactElement> \\| Iterable \\| ReactPortal \\| Promise | null | The component type to render. |
| asChild | boolean | false | Whether the component should be rendered as a child component. |
| pt | SafeRecord | null | The pass-through props to pass to the component |
| ptOptions | PassThroughOptions | null | The pass-through options to pass to the component |
| unstyled | boolean | null | Whether the component should be rendered without classes. |
| dt | unknown | null | The design token to use for the component. |
| styles | StylesOptions | null | The styles to use for the component. |
| children | ReactNode \\| ((instance: DividerInstance) => ReactNode) | null | The children to render. |
| align | "center" \\| "left" \\| "right" \\| "top" \\| "bottom" | null | Alignment of the content. |
| orientation | "horizontal" \\| "vertical" | horizontal | Specifies the orientation, valid values are 'horizontal' and 'vertical'. |
| type | "solid" \\| "dashed" \\| "dotted" | solid | Border style type. |
| [key: string] | any | null | |
| pt-{optionName}-* | - | null | Pass through attributes for customizing component. For more info, see Pass Through tab. |
### Interfaces
| Label | Description | Data |
|:------|:------|:------|
| PassThroughOptions | Defines passthrough(pt) options of Divider component. | [object Object],[object Object] |
### Types
| Label | Description | Data |
|:------|:------|:------|
| Instance | Instance of Divider component. | [object Object] |
## DividerContent
### Props
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| ref | Ref | null | The reference to the component instance. |
| pIf | boolean | true | Whether the component should be rendered. |
| style | CSSProperties \\| ((instance?: DividerContentInstance) => CSSProperties) | null | The style to apply to the component. |
| className | string \\| ((instance?: DividerContentInstance) => string) | null | The class name to apply to the component. |
| as | string \\| number \\| bigint \\| boolean \\| ComponentClass \\| FunctionComponent \\| ReactElement> \\| Iterable \\| ReactPortal \\| Promise | null | The component type to render. |
| asChild | boolean | false | Whether the component should be rendered as a child component. |
| pt | SafeRecord | null | The pass-through props to pass to the component |
| ptOptions | PassThroughOptions | null | The pass-through options to pass to the component |
| unstyled | boolean | null | Whether the component should be rendered without classes. |
| dt | unknown | null | The design token to use for the component. |
| styles | StylesOptions | null | The styles to use for the component. |
| children | ReactNode \\| ((instance: DividerContentInstance) => ReactNode) | null | The children to render. |
| [key: string] | any | null | |
| pt-{optionName}-* | - | null | Pass through attributes for customizing component. For more info, see Pass Through tab. |
### Exposes
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| divider | DividerInstance | null | Instance of the Divider component. |
### Interfaces
| Label | Description | Data |
|:------|:------|:------|
| PassThroughOptions | Defines passthrough(pt) options of DividerContent component. | [object Object] |
### Types
| Label | Description | Data |
|:------|:------|:------|
| Instance | Instance of DividerContent component. | [object Object] |
## useDivider
### Types
| Label | Description | Data |
|:------|:------|:------|
| Instance | Instance of useDivider headless. | [object Object] |
# Divider
Divider is used to separate contents.
## Usage
```tsx
import { Divider } from 'primereact/divider';
```
```tsx
```
## Examples
### Basic
Divider is basically placed between the items to separate.
```tsx
import { Divider } from 'primereact/divider';
export default function BasicDemo() {
return (
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam
voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Consectetur, adipisci velit, sed quia non numquam eius modi.
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui
officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus.
Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis
voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat. Donec vel volutpat ipsum. Integer nunc magna, posuere ut tincidunt eget, egestas vitae sapien. Morbi dapibus luctus odio.
);
}
```
### Type
Style of the border is configured with the `type` property that can either be `solid`, `dotted` or `dashed`.
```tsx
import { Divider } from 'primereact/divider';
export default function TypeDemo() {
return (
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam
voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Consectetur, adipisci velit, sed quia non numquam eius modi.
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui
officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus.
Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis
voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat. Donec vel volutpat ipsum. Integer nunc magna, posuere ut tincidunt eget, egestas vitae sapien. Morbi dapibus luctus odio.
);
}
```
### Vertical
Vertical divider is enabled by setting the `orientation` property as `vertical`.
```tsx
import { Divider } from 'primereact/divider';
export default function VerticalDemo() {
return (
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam
voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Consectetur, adipisci velit, sed quia non numquam eius modi.
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui
officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus.
);
}
```
### Content
Children are rendered within the boundaries of the divider where location of the content is configured with the `align` property. In horizontal orientation, alignment options are `left`, `center` and`right` whereas vertical
mode supports `top`, `center` and `bottom`.
```tsx
import { Divider } from 'primereact/divider';
export default function ContentDemo() {
return (
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Left
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam
voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Consectetur, adipisci velit, sed quia non numquam eius modi.
Center
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui
officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus.
Right
Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis
voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat. Donec vel volutpat ipsum. Integer nunc magna, posuere ut tincidunt eget, egestas vitae sapien. Morbi dapibus luctus odio.
);
}
```
### Login
Sample implementation of a login form using a divider with content.
```tsx
import { Button } from 'primereact/button';
import { Divider } from 'primereact/divider';
import { InputText } from 'primereact/inputtext';
import { Label } from 'primereact/label';
export default function LoginDemo() {
return (
OR
);
}
```
## Accessibility
### Screen Reader
Divider uses a `separator` role with `aria-orientation` set to either "horizontal" or "vertical".
### Keyboard Support
Component does not include any interactive elements.
# Divider Pass Through
Pass Through documentation for Divider component
## Viewer
Some sections may not be visible due to the availability of the particular feature.
## Divider PT Options
| Label | Type | Description |
|:------|:------|:------|
| root | DividerPassThroughType> | Used to pass attributes to the root's DOM element. |
| content | DividerPassThroughType> | Used to pass attributes to the content's DOM element. |
## DividerContent PT Options
| Label | Type | Description |
|:------|:------|:------|
| root | DividerContentPassThroughType> | Used to pass attributes to the root's DOM element. |
# Divider Theming
Theming documentation for Divider component
## Styled
### CSS Classes
List of class names used in the styled mode.
| ClassName | Description |
|:------|:------|
| p-divider | Class name of the root element |
| p-divider-content | Class name of the content element |
### Design Tokens
List of design tokens.
| Token | CSS Variable | Description |
|:------|:------|:------|
| divider.border.color | --p-divider-border-color | Border color of root |
| divider.content.background | --p-divider-content-background | Background of content |
| divider.content.color | --p-divider-content-color | Color of content |
| divider.horizontal.margin | --p-divider-horizontal-margin | Margin of horizontal |
| divider.horizontal.padding | --p-divider-horizontal-padding | Padding of horizontal |
| divider.horizontal.content.padding | --p-divider-horizontal-content-padding | Content padding of horizontal |
| divider.vertical.margin | --p-divider-vertical-margin | Margin of vertical |
| divider.vertical.padding | --p-divider-vertical-padding | Padding of vertical |
| divider.vertical.content.padding | --p-divider-vertical-content-padding | Content padding of vertical |
## Unstyled
Theming is implemented with the pass through properties in unstyled mode.
# Fieldset API
API documentation for Fieldset component
## Fieldset
### Props
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| ref | Ref | null | The reference to the component instance. |
| pIf | boolean | true | Whether the component should be rendered. |
| style | CSSProperties \\| ((instance?: FieldsetInstance) => CSSProperties) | null | The style to apply to the component. |
| className | string \\| ((instance?: FieldsetInstance) => string) | null | The class name to apply to the component. |
| as | string \\| number \\| bigint \\| boolean \\| ComponentClass \\| FunctionComponent \\| ReactElement> \\| Iterable \\| ReactPortal \\| Promise | null | The component type to render. |
| asChild | boolean | false | Whether the component should be rendered as a child component. |
| pt | SafeRecord | null | The pass-through props to pass to the component |
| ptOptions | PassThroughOptions | null | The pass-through options to pass to the component |
| unstyled | boolean | null | Whether the component should be rendered without classes. |
| dt | unknown | null | The design token to use for the component. |
| styles | StylesOptions | null | The styles to use for the component. |
| children | ReactNode \\| ((instance: FieldsetInstance) => ReactNode) | null | The children to render. |
| [key: string] | any | null | |
| pt-{optionName}-* | - | null | Pass through attributes for customizing component. For more info, see Pass Through tab. |
### Interfaces
| Label | Description | Data |
|:------|:------|:------|
| PassThroughOptions | Defines passthrough(pt) options of Fieldset component. | [object Object],[object Object],[object Object] |
### Types
| Label | Description | Data |
|:------|:------|:------|
| Instance | Instance of Fieldset component. | [object Object] |
## FieldsetLegend
### Props
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| ref | Ref | null | The reference to the component instance. |
| pIf | boolean | true | Whether the component should be rendered. |
| style | CSSProperties \\| ((instance?: FieldsetLegendInstance) => CSSProperties) | null | The style to apply to the component. |
| className | string \\| ((instance?: FieldsetLegendInstance) => string) | null | The class name to apply to the component. |
| as | string \\| number \\| bigint \\| boolean \\| ComponentClass \\| FunctionComponent \\| ReactElement> \\| Iterable \\| ReactPortal \\| Promise | null | The component type to render. |
| asChild | boolean | false | Whether the component should be rendered as a child component. |
| pt | SafeRecord | null | The pass-through props to pass to the component |
| ptOptions | PassThroughOptions | null | The pass-through options to pass to the component |
| unstyled | boolean | null | Whether the component should be rendered without classes. |
| dt | unknown | null | The design token to use for the component. |
| styles | StylesOptions | null | The styles to use for the component. |
| children | ReactNode \\| ((instance: FieldsetLegendInstance) => ReactNode) | null | The children to render. |
| [key: string] | any | null | |
| pt-{optionName}-* | - | null | Pass through attributes for customizing component. For more info, see Pass Through tab. |
### Exposes
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| fieldset | FieldsetInstance | null | The Fieldset component instance. |
### Interfaces
| Label | Description | Data |
|:------|:------|:------|
| PassThroughOptions | Defines passthrough(pt) options of FieldsetLegend component. | [object Object] |
### Types
| Label | Description | Data |
|:------|:------|:------|
| Instance | Instance of FieldsetLegend component. | [object Object] |
## FieldsetContent
### Props
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| ref | Ref | null | The reference to the component instance. |
| pIf | boolean | true | Whether the component should be rendered. |
| style | CSSProperties \\| ((instance?: FieldsetContentInstance) => CSSProperties) | null | The style to apply to the component. |
| className | string \\| ((instance?: FieldsetContentInstance) => string) | null | The class name to apply to the component. |
| as | string \\| number \\| bigint \\| boolean \\| ComponentClass \\| FunctionComponent \\| ReactElement> \\| Iterable \\| ReactPortal \\| Promise | null | The component type to render. |
| asChild | boolean | false | Whether the component should be rendered as a child component. |
| pt | SafeRecord | null | The pass-through props to pass to the component |
| ptOptions | PassThroughOptions | null | The pass-through options to pass to the component |
| unstyled | boolean | null | Whether the component should be rendered without classes. |
| dt | unknown | null | The design token to use for the component. |
| styles | StylesOptions | null | The styles to use for the component. |
| children | ReactNode \\| ((instance: FieldsetContentInstance) => ReactNode) | null | The children to render. |
| [key: string] | any | null | |
| pt-{optionName}-* | - | null | Pass through attributes for customizing component. For more info, see Pass Through tab. |
### Exposes
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| fieldset | FieldsetInstance | null | The Switch component instance. |
### Interfaces
| Label | Description | Data |
|:------|:------|:------|
| PassThroughOptions | Defines passthrough(pt) options of FieldsetContent component. | [object Object] |
### Types
| Label | Description | Data |
|:------|:------|:------|
| Instance | Instance of FieldsetContent component. | [object Object] |
## useFieldset
### Types
| Label | Description | Data |
|:------|:------|:------|
| Instance | Instance of useFieldset headless. | [object Object] |
# Fieldset
Fieldset visually integrates a label with its form element.
## Usage
```tsx
import { Fieldset } from 'primereact/fieldset';
```
```tsx
```
## Examples
### Basic
Demonstrates a simple fieldset component with a legend and content for organizing related information in a structured manner.
```tsx
import { Fieldset } from 'primereact/fieldset';
export default function BasicDemo() {
return (
);
}
```
### Toggleable
Shows a fieldset with collapsible content that can be shown or hidden by clicking on the legend.
```tsx
import { Motion } from '@primereact/core/motion';
import { MinusIcon, PlusIcon } from '@primereact/icons';
import { Button } from 'primereact/button';
import { Fieldset } from 'primereact/fieldset';
import * as React from 'react';
export default function ToggleableDemo() {
const [show, setShow] = React.useState(true);
return (
);
}
```
## Accessibility
### Screen Reader
Fieldset component uses the semantic fieldset element.
### Keyboard Support
| Key | Function |
| ----------- | --------------------------------------------------------------------------- |
| tab | Moves focus to the next the focusable element in the page tab sequence. |
| shift + tab | Moves focus to the previous the focusable element in the page tab sequence. |
| enter | Toggles the visibility of the content. |
| space | Toggles the visibility of the content. |
# Fieldset Pass Through
Pass Through documentation for Fieldset component
## Viewer
Some sections may not be visible due to the availability of the particular feature.
## Fieldset PT Options
| Label | Type | Description |
|:------|:------|:------|
| root | FieldsetPassThroughType> | Used to pass attributes to the root's DOM element. |
| legend | FieldsetPassThroughType> | Used to pass attributes to the legend's DOM element. |
| content | FieldsetPassThroughType> | Used to pass attributes to the content's DOM element. |
## FieldsetLegend PT Options
| Label | Type | Description |
|:------|:------|:------|
| root | FieldsetLegendPassThroughType> | Used to pass attributes to the root's DOM element. |
## FieldsetContent PT Options
| Label | Type | Description |
|:------|:------|:------|
| root | FieldsetContentPassThroughType> | Used to pass attributes to the root's DOM element. |
# Fieldset Theming
Theming documentation for Fieldset component
## Styled
### CSS Classes
List of class names used in the styled mode.
| ClassName | Description |
|:------|:------|
| p-fieldset | Class name of the root element |
| p-fieldset-legend | Class name of the legend element |
| p-fieldset-content | Class name of the content element |
### Design Tokens
List of design tokens.
| Token | CSS Variable | Description |
|:------|:------|:------|
| fieldset.background | --p-fieldset-background | Background of root |
| fieldset.border.color | --p-fieldset-border-color | Border color of root |
| fieldset.border.radius | --p-fieldset-border-radius | Border radius of root |
| fieldset.color | --p-fieldset-color | Color of root |
| fieldset.padding | --p-fieldset-padding | Padding of root |
| fieldset.transition.duration | --p-fieldset-transition-duration | Transition duration of root |
| fieldset.legend.background | --p-fieldset-legend-background | Background of legend |
| fieldset.legend.hover.background | --p-fieldset-legend-hover-background | Hover background of legend |
| fieldset.legend.color | --p-fieldset-legend-color | Color of legend |
| fieldset.legend.hover.color | --p-fieldset-legend-hover-color | Hover color of legend |
| fieldset.legend.border.radius | --p-fieldset-legend-border-radius | Border radius of legend |
| fieldset.legend.border.width | --p-fieldset-legend-border-width | Border width of legend |
| fieldset.legend.border.color | --p-fieldset-legend-border-color | Border color of legend |
| fieldset.legend.padding | --p-fieldset-legend-padding | Padding of legend |
| fieldset.legend.gap | --p-fieldset-legend-gap | Gap of legend |
| fieldset.legend.font.weight | --p-fieldset-legend-font-weight | Font weight of legend |
| fieldset.legend.focus.ring.width | --p-fieldset-legend-focus-ring-width | Focus ring width of legend |
| fieldset.legend.focus.ring.style | --p-fieldset-legend-focus-ring-style | Focus ring style of legend |
| fieldset.legend.focus.ring.color | --p-fieldset-legend-focus-ring-color | Focus ring color of legend |
| fieldset.legend.focus.ring.offset | --p-fieldset-legend-focus-ring-offset | Focus ring offset of legend |
| fieldset.legend.focus.ring.shadow | --p-fieldset-legend-focus-ring-shadow | Focus ring shadow of legend |
| fieldset.toggle.icon.color | --p-fieldset-toggle-icon-color | Color of toggle icon |
| fieldset.toggle.icon.hover.color | --p-fieldset-toggle-icon-hover-color | Hover color of toggle icon |
| fieldset.content.padding | --p-fieldset-content-padding | Padding of content |
## Unstyled
Theming is implemented with the pass through properties in unstyled mode.
# FloatLabel API
API documentation for FloatLabel component
## FloatLabel
### Props
| Name | Type | Default | Description |
|:------|:------|:------|:------|
| ref | Ref | null | The reference to the component instance. |
| pIf | boolean | true | Whether the component should be rendered. |
| style | CSSProperties \\| ((instance?: FloatLabelInstance) => CSSProperties) | null | The style to apply to the component. |
| className | string \\| ((instance?: FloatLabelInstance) => string) | null | The class name to apply to the component. |
| as | string \\| number \\| bigint \\| boolean \\| ComponentClass \\| FunctionComponent \\| ReactElement> \\| Iterable \\| ReactPortal \\| Promise | null | The component type to render. |
| asChild | boolean | false | Whether the component should be rendered as a child component. |
| pt | SafeRecord