CarsXE

Search docs

Search pages, components, and skills.

Rating group

A star rating that can be read or set. It supports half values from the click position, an optional clear affordance, any icon pair for the filled and empty layers, a custom number of items, vertical layout, read-only and disabled states, and form submission through a hidden input. Arrow keys step the rating; with allowClear, Delete and Backspace reset it.

Rated 3 of 5.

Installation

Import from the package. Do not run shadcn add in your app.

tsx
import { RatingGroup } from "@carsxe/design-system/components/rating-group"

Usage

tsx
import { RatingGroup } from "@carsxe/design-system/components/rating-group"

const [value, setValue] = React.useState(3)

<RatingGroup aria-label="Rate this endpoint" value={value} onValueChange={setValue} />

Half values

Clearable

Pick the same star again, or press Delete, to clear.

Custom icons

Item count

Vertical

Read-only and disabled

Inside a form

API Reference

PropTypeDefault
valuenumber—
defaultValuenumber0
onValueChange(value: number) => void—
countnumber5
allowHalfbooleanfalse
allowClearbooleanfalse
iconComponentType<{ className?: string }>—
emptyIconComponentType<{ className?: string }>—
orientation"horizontal" | "vertical""horizontal"
readOnlybooleanfalse
disabledbooleanfalse
namestring—