<span class="cap-rating"><span role="img" aria-label="3.5 out of 5 stars" class="cap-rating-img">
<span class="cap-rating-stars" data-half="7" aria-hidden="true"><span class="cap-rating-empty">☆☆☆☆☆</span><span class="cap-rating-fill">★★★★★</span></span>
</span><span class="cap-rating-note">(12 ratings)</span></span>
Examples
Sizes
<div data-mount="sizes" id="sample-sizes"></div>
Asked for
<div data-mount="input" id="sample-input"></div>
API reference
Rating
Prop
Type
Required
Does
value
number
Yes
children
ReactNode
Words after the stars ("(12 ratings)"), visible.
size
"sm" | "default" | "lg"
className
string
RatingInput
Prop
Type
Required
Does
name
string
Yes
label
string
Yes
defaultValue
number
Half stars, 0 for none. Uncontrolled with defaultValue, controlled with value and onChange.
value
number
onChange
(value: number) => void
noneLabel
string
Words for "no rating" (the empty choice).
whole
boolean
Allow only whole stars.
id
string
CSS variables
Variable
Default
--_fill
0%
--_star
1.1em
Parts and data attributes
Class
Is
.cap-rating
the root
.cap-rating-control
a part
.cap-rating-empty
a part
.cap-rating-fill
a part
.cap-rating-img
a part
.cap-rating-note
a part
.cap-rating-stars
a part
Attribute
Values
data-half
011023456789
data-size
lgsm
Accessibility
Key
Does
Arrow keys on the select
Change the rating
Forced colors: the fill is CanvasText and the outline GrayText.
Screen readers: no manual NVDA or VoiceOver run, by decision (2026-11-07); the automated browser checks and a front-end review stand in. Automated: see the site's Tests page.