Rating

Rating is a component used to allow users to provide ratings.

Usage

import { Rating } from "@yamada-ui/react"
<Rating />

Change Size

Change Color Scheme

Set Default Value

To set a default value, assign a number to defaultValue.

Change Number of Items

To change the number of items, assign a number to count.

Set Decimals

To set decimals, assign a number to fractions.

For example, to set 0.25, set 4.

Highlight Selected Only

To highlight only the selected rating, set highlightSelectedOnly to true.

Change Color

To change the color, assign a string or function to color.

Disable

To disable, set disabled to true.

Read-Only

To make it read-only, set readOnly to true.

Customize Icons

To customize icons, assign ReactNode or a function to emptyIcon and filledIcon.

Control

Props

Accessibility

The Rating follows the WAI-ARIA - Radio Group Pattern for accessibility.

Setting aria-label or aria-labelledby on Rating will make it readable by screen readers.

<Rating aria-label="Rating" />
<VStack gap="sm">
  <Heading as="h3" id="label">
    Rating
  </Heading>

  <Rating aria-labelledby="label" />
</VStack>

Keyboard Navigation

KeyDescriptionState
TabFocus on the selected item. If no item is selected, focus on the first item.-
ArrowLeft, ArrowUpFocus on and select the previous item. If the first item is selected, select the last item. Deselect the previously selected item.-
ArrowRight, ArrowDownFocus on and select the next item. If the last item is selected, focus on and select the first item. The previously selected item will be deselected.-

ARIA Roles and Attributes

ComponentRole and AttributeUsage
Ratingrole="radiogroup"Indicates that this is a radio group.
aria-labelIndicates the number of selected items.
aria-readonlySet to "true" when readOnly is specified.
aria-disabledSet to "true" when disabled is specified.
RatingItemaria-labelSet value.
RatingIconaria-hidden="true"Exclude RatingIcon from the accessibility tree.