lara-light-indigo

Rating

Rating component is a star based selection input.

Basic
Without Cancel
ReadOnly
Disabled
Template
custom-cancel-image
custom-image
custom-image
custom-image
custom-image
custom-image
Import via Module

import { Rating } from 'primereact/rating';
 
Import via CDN

<script src="https://unpkg.com/primereact/core/core.min.js"></script>
<script src="https://unpkg.com/primereact/rating/rating.min.js"></script>
 
Getting Started

Rating is used a controlled input component with value and onChange properties.


<Rating value={value} onChange={(e) => setValue(e.value)} />
 
Number of Stars

Number of stars to display is defined with stars property, default is 5.


<Rating value={value} onChange={(e) => setValue(e.value)} stars={5} />
 
Cancel

A cancel icon is displayed to reset the value by default, set cancel as false to remove this option.


<Rating value={value} onChange={(e) => setValue(e.value)} cancel={false} />
 
Custom Icons

Custom icons are used to override the default icons with onIcon, offIcon and cancelIcon properties.


<Rating value={value} onIcon="pi pi-circle-fill" offIcon="pi-circle" onChange={(e) => setValue(e.value)} />
 
Properties

Any valid attribute is passed to the root element implicitly, extended properties are as follows;

NameTypeDefaultDescription
idstringnullUnique identifier of the element.
valuenumbernullValue of the rating.
disabledbooleanfalseWhen present, it specifies that the element should be disabled.
readOnlybooleanfalseWhen present, changing the value is not possible.
styleobjectnullInline style of the component.
classNamestringnullClassName of the component.
starsnumber5Number of stars.
cancelbooleantrueWhen specified a cancel icon is displayed to allow removing the value.
cancelIconstringpi pi-banClassName of the cancel icon component.
cancelIconPropsobjectnullProperties of the cancel icon.
onIconstringpi pi-star-fillClassName of the on icon component.
offIconstringpi pi-starClassName of the off icon component.
onIconPropsobjectnullProperties of the on icon.
offIconPropsobjectnullProperties of the off icon.
tooltipanynullContent of the tooltip.
tooltipOptionsobjectnullConfiguration of the tooltip, refer to the tooltip documentation for more information.
Events
NameParametersDescription
onChangeevent.originalEvent: Browser event
event.value: selected value
Callback to invoke on value change.
Styling

Following is the list of structural style classes

NameElement
p-ratingContainer element
p-rating-itemEach item element
p-rating-item-activeSelected item elements.
p-rating-cancel-itemCancel item element.
Accessibility

This section is under development. After the necessary tests and improvements are made, it will be shared with the users as soon as possible.

Dependencies

None.

Component Scale

Input Style

Ripple Effect

Free Themes

Built-in component themes created by the PrimeReact Theme Designer.

Bootstrap
Blue
Purple
Blue
Purple
Material Design
Indigo
Deep Purple
Indigo
Deep Purple
Material Design Compact
Indigo
Deep Purple
Indigo
Deep Purple
Tailwind
Tailwind Light
Fluent UI
Blue
PrimeOne Design - 2022 NEW
Lara Indigo
Lara Blue
Lara Purple
Lara Teal
Lara Indigo
Lara Blue
Lara Purple
Lara Teal
PrimeOne Design - 2021
Saga Blue
Saga Green
Saga Orange
Saga Purple
Vela Blue
Vela Green
Vela Orange
Vela Purple
Arya Blue
Arya Green
Arya Orange
Arya Purple
Premium Themes

Premium themes are only available exclusively for PrimeReact Theme Designer subscribers and therefore not included in PrimeReact core.

Soho Light
Soho Dark
Viva Light
Viva Dark
Mira
Nano

Legacy Free Themes

Nova
Nova Alt
Nova Accent
Luna Blue
Luna Green
Luna Amber
Luna Pink
Rhea

Premium Create-React-App Templates

Beautifully crafted premium create-react-app application templates by the PrimeTek design team.

Sakai
Atlantis
Freya
Ultima
Diamond
Sapphire
Serenity
Babylon
Avalon
Apollo
Roma