Skip to content
THE COMPONENT LIBRARY
Skip to content

Component reference

Rating

An editable product rating with local feedback.

Preview

Live preview

Changes apply to this preview only.

3 of 5
Product rating

Click the selected star again to clear the rating. Arrow keys, Home and End also work.

Width adapts to the available space

More examples

Different configurations and compositions using the real Pimolu API. Each preview runs independently and follows the site appearance.

Sizes

sm, md and lg scale the stars and the visible label together.

Open preview

Read-only

readOnly keeps the radiogroup semantics and announces aria-readonly, but clicks and keys do not change the value.

Open preview

Disabled and custom scales

max changes the number of stars; getLabel replaces the default accessible star labels; disabled removes every star from the tab order.

Open preview

Usage

Keep the numeric rating separate from the number of reviews and define the scale clearly.

API reference

Generated from the public TypeScript declarations. Native HTML attributes are inherited where the component extends them; this reference includes Pimolu props and selected common native attributes.

PimoluRatingProps

Type source
PimoluRatingProps public API
NameTypeDefaultDescription
valuenumber | undefined—Controlled rating. Use 0 for "no rating".
defaultValuenumber | undefined0Initial rating when uncontrolled. Defaults to 0.
onValueChange((value: number) => void) | undefined—Called with the next rating, or 0 when cleared.
maxnumber | undefined5Number of stars. Defaults to 5.
readOnlyboolean | undefinedfalseShow the rating without allowing changes.
disabledboolean | undefinedfalsePublic Pimolu prop; see the source declaration for details.
sizePimoluRatingSize | undefined"md"Visual size. Defaults to "md".
allowClearboolean | undefinedfalseClick the current rating again to clear it. Defaults to false.
labelReactNode—Visible label, also used to name the group.
getLabel((value: number) => string) | undefined"N star(s)"Accessible name for each star. Defaults to "N star(s)".
classNamestring | undefined—Standard React/HTML attribute.
styleCSSProperties | undefined—Standard React/HTML attribute.
aria-labelstring | undefined—Defines a string value that labels the current element.
childrenReactNode—Standard React/HTML attribute.
onClickMouseEventHandler<HTMLDivElement> | undefined—Standard React/HTML attribute.
value

number | undefined

No default extracted.

Controlled rating. Use 0 for "no rating".

defaultValue

number | undefined

Default: 0

Initial rating when uncontrolled. Defaults to 0.

onValueChange

((value: number) => void) | undefined

No default extracted.

Called with the next rating, or 0 when cleared.

max

number | undefined

Default: 5

Number of stars. Defaults to 5.

readOnly

boolean | undefined

Default: false

Show the rating without allowing changes.

disabled

boolean | undefined

Default: false

Public Pimolu prop; see the source declaration for details.

size

PimoluRatingSize | undefined

Default: "md"

Visual size. Defaults to "md".

allowClear

boolean | undefined

Default: false

Click the current rating again to clear it. Defaults to false.

label

ReactNode

No default extracted.

Visible label, also used to name the group.

getLabel

((value: number) => string) | undefined

Default: "N star(s)"

Accessible name for each star. Defaults to "N star(s)".

className

string | undefined

No default extracted.

Standard React/HTML attribute.

style

CSSProperties | undefined

No default extracted.

Standard React/HTML attribute.

aria-label

string | undefined

No default extracted.

Defines a string value that labels the current element.

children

ReactNode

No default extracted.

Standard React/HTML attribute.

onClick

MouseEventHandler<HTMLDivElement> | undefined

No default extracted.

Standard React/HTML attribute.

Accessibility

  • Name the rating control and check keyboard selection; do not communicate the value only with stars.
Read the accessibility guide →