Rating Group

Allows users to rate items using a set of icons.

Star IconStar IconStar IconStar IconStar Icon

Anatomy

To set up the rating correctly, you’ll need to understand its anatomy and how we name its parts.

Each part includes a data-part attribute to help identify them in the DOM.

Examples

Learn how to use the RatingGroup component in your project. Let’s take a look at the most basic example:

Using half ratings

Allow 0.5 value steps by setting the allowHalf prop to true. Ensure to render the correct icon if the isHalf value is set in the Rating components render callback.

Using a default value

Controlled

When using the RatingGroup component, you can use the value and onValueChange props to control the state.

Disabling the rating group

To make the rating group disabled, set the disabled prop to true.

Readonly rating group

To make the rating group readonly, set the readOnly prop to true.

Usage within forms

To use the rating group within forms, pass the prop name. It will render a hidden input and ensure the value changes get propagated to the form correctly.

API Reference

Root

PropTypeDefault
allowHalf
boolean
asChild
boolean
autoFocus
boolean
count
number
defaultValue
number
disabled
boolean
form
string
id
string
ids
Partial<{ root: string label: string hiddenInput: string control: string rating(id: string): string }>
name
string
onHoverChange
(details: HoverChangeDetails) => void
onValueChange
(details: ValueChangeDetails) => void
readOnly
boolean
translations
IntlTranslations
value
number

Control

PropTypeDefault
asChild
boolean

HiddenInput

PropTypeDefault
asChild
boolean

Item

PropTypeDefault
index
number
asChild
boolean

Label

PropTypeDefault
asChild
boolean