React Rating Component
Rating
Limited-time offer for the first 100 customers in 2025. Use code 2025SKY25 at checkout.
A React star rating component allows users to rate and provide feedback on content or products by selecting a specified number of stars, typically ranging from one to five, representing their level of satisfaction or preference.
Other Frameworks
CoreUI components are available as native Angular, Bootstrap (Vanilla JS), and Vue components. To learn more please visit the following pages.
How to use React Rating Component.#
Embed the Rating component in your React application like this:
Allow clear#
Enable users to clear their selected rating by clicking on the current rating again. This functionality is activated by setting allowClear
boolean property.
This allows the selected rating to be deselected, effectively resetting the rating to a state where no value is selected.
Resettable#
Our React Rating component allows users to assign and reset a star rating within a user interface. In the example below, we use the CButton
component to clear the selected value by passing null
.
Read only#
Set the React rating component to read-only by adding readOnly
property. This disables interaction, preventing users from changing the displayed rating value.
Disabled#
Add the disabled
boolean property to give it a grayed out appearance, remove pointer events, and prevent focusing.
Tooltips#
Enable descriptive text on hover by adding tooltips
prop. This provides immediate feedback or guidance as the user interacts with the rating items.
For custom messages, provide an array of labels corresponding to each rating value to enhance the user's understanding of each rating level.
Sizes#
Larger or smaller react rating component? Add size="lg"
or size="sm"
for additional sizes.
Precision#
Adjust the granularity of the Rating component by setting precision
prop. This attribute allows for fractional ratings, such as quarter values, to provide more precise feedback.
Number of items#
Control the total number of rating items displayed by using itemCount
property. You can create a React rating component with a custom scale, be it larger for detailed assessments or smaller for simplicity.
Custom icons#
Customize the React rating component with your choice of SVG icons by assigning new values to the activeIcon
and icon
properties in the JavaScript options. This allows for a unique look tailored to the design language of your site or application.
The Rating component can be customized with either SVG or font icons, allowing for visual alignment with your application's design. You can specify different icons for each rating value to enhance user interaction.
In the example below, we demonstrate how to set custom icons using SVG, allowing for detailed customization of the visual elements within the Rating component.
In the example below, we use font icons from the CoreUI Icons set. In the activeIcon
configuration, we also apply the utility class text-danger
to change the icon's color to red when it is active.
For a more dynamic experience, define different icons for each rating value, enhancing the visual feedback:
Custom feedback#
The React Rating component integrates interactive star ratings with dynamic textual feedback using other components from CoreUI. It enables users to select a rating that updates the display and label in real-time, enhancing the interactive experience. Hover effects provide immediate feedback on potential ratings before selection, ensuring an intuitive user interface.
API#
Check out the documentation below for a comprehensive guide to all the props you can use with the components mentioned here.