Skip to Content
Documentation
Getting startedComponentsChartsTheming
Get Pro
Overview
Concepts

Rating

Used to show reviews and ratings in a visual format.

Recipe

Anatomy

import { RatingGroup } from '@chakra-ui/react'
<RatingGroup.Root>
  <RatingGroup.Label />
  <RatingGroup.HiddenInput />
  <RatingGroup.Control>
    <RatingGroup.Item>
      <RatingGroup.ItemIndicator />
    </RatingGroup.Item>
  </RatingGroup.Control>
</RatingGroup.Root>

If you don't need to customize the rating icons, render RatingGroup.Control without children. It renders the number of rating items specified in the count prop.

<RatingGroup.Root count={5} defaultValue={3}>
  <RatingGroup.HiddenInput />
  <RatingGroup.Control />
</RatingGroup.Root>

Examples

Basic

Use the count prop to set the number of rating items, and defaultValue to set the initial rating.

Sizes

Use the size prop to change the size of the rating component.

Controlled

Use the value and onValueChange prop to control the rating value.

Read Only

Use the readOnly prop to make the rating component read-only. This is useful when displaying an existing rating.

Half Star

Use the allowHalf prop to allow half-star ratings.

Custom Icon

Use the icon prop on RatingGroup.ItemIndicator to pass a custom icon to the rating component. This will override the default star icon.

Testimonial

Use the rating component to show testimonials.

Saas UI saved us months of work. The components are well thought out and a joy to build with.

MJ

Matthew Jones

CTO, Company

Props

Root

PropDefaultType
count '5'
number

The total number of ratings.

colorPalette 'gray'
'base' | 'gray' | 'zinc' | 'neutral' | 'stone' | 'red' | 'orange' | 'amber' | 'yellow' | 'lime' | 'green' | 'emerald' | 'teal' | 'cyan' | 'sky' | 'blue' | 'indigo' | 'violet' | 'purple' | 'fuchsia' | 'pink' | 'rose' | 'sidebar' | 'sidebar.accent' | 'interaction' | 'accent' | 'presence' | 'status' | 'slate'

The color palette of the component

size 'md'
'xs' | 'sm' | 'md' | 'lg'

The size of the component

allowHalf
boolean

Whether to allow half stars.

asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

For more details, read our Composition guide.
autoFocus
boolean

Whether to autofocus the rating.

defaultValue
number

The initial value of the rating when rendered. Use when you don't need to control the value of the rating.

disabled
boolean

Whether the rating is disabled.

form
string

The associate form of the underlying input element.

id
string

The unique identifier of the machine.

ids
Partial<{ root: string label: string hiddenInput: string control: string item: (id: string) => string }>

The ids of the elements in the rating. Useful for composition.

name
string

The name attribute of the rating element (used in forms).

onHoverChange
(details: HoverChangeDetails) => void

Function to be called when the rating value is hovered.

onValueChange
(details: ValueChangeDetails) => void

Function to be called when the rating value changes.

readOnly
boolean

Whether the rating is readonly.

required
boolean

Whether the rating is required.

translations
IntlTranslations

Specifies the localized strings that identifies the accessibility elements and their states

value
number

The controlled value of the rating

as
React.ElementType

The underlying element to render.

unstyled
boolean

Whether to remove the component's style.

Item

PropDefaultType
index *
number

asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

For more details, read our Composition guide.

Previous

Radio

Next

Segmented Control