Avaliação por estrelas, para exibição (precisão decimal real: 4,3 preenche 30% da 5ª estrela, número de avaliações como link) ou como entrada integrada a formulários: meias estrelas, prévia ao passar o mouse, legendas como “Very good”, suporte completo a teclado, limpeza, obrigatório; variante compacta ★ 4,8 (2.413).
A product card or listing shows an average rating with decimal precision and a review count
A review form asks users to rate from one to five stars, optionally with half stars
A compact star, score and count summary must fit in a tight row
Avoid when
A full reviews section with histogram, filters and review cards is needed → use Review instead
The score is a satisfaction or NPS scale from 0 to 10 where stars would be misleading → use Radio instead
Instalação
node scripts/add.mjs rating --out ./src/marvelous
Agente de IA com o servidor MCP do Marvelous UI: install_components({ slugs: ["rating"], target_dir: "<absolute path>/src/marvelous", framework: "react" }).
Rating (0 = none). Observed: a framework can drive it via the attribute.
max
number
5
Number of stars.
precision
1 | 0.5
1
Input step (0.5 = half stars).
readonly
boolean
Display mode: role=img, unrounded value.
clearable
boolean
Clicking the current rating again clears it.
name / required / disabled
string / boolean
Form: submitted value “4.5”, valueMissing when required and empty.
count
number
Review count shown (“128 reviews”).
href
string
Turns the review count into a link (anchor to the reviews section).
show-value
boolean
Shows the numeric rating (“4.6”).
label
string
Rating
Accessible name (otherwise <label for>).
captions
string
Poor,Fair,Good,Very good,Excellent
Per-star captions, shown during input and read in aria-valuetext.
locale
string
en-US
Number formatting.
data-size
sm | lg | xl
Star size.
data-variant
compact
One star + rating + (count).
invalid
boolean
Error style.
Properties
Name
Tipo
Description
value
number
Current rating.
form / validity / labels
Via ElementInternals.
Methods
Name
Description
focus()
Focuses the star slider.
checkValidity() / reportValidity()
Native validation.
Events
Name
Description
mv-change
User change. detail: { value, label }.
CSS classes
Name
Description
mv-rating-stars / -star / -value / -text / -count
Generated parts; --_fill (0…1) on each star.
CSS variables
Name
Default
Description
--mv-rating-size
1.125rem
Size of one star.
--mv-rating-color
var(--mv-warning)
Filled stars.
--mv-rating-empty-color
gray
Empty stars.
Accessibility
Display: role=img with aria-label “Rating: 4.6 out of 5 (128 reviews)”. Input: APG “Rating slider” pattern, a single focusable role=slider element, aria-valuenow / aria-valuetext (“4 stars out of 5, Very good” or “No rating”). Arrow keys ±precision (reversed in RTL), Page Up/Down ±1, Home/End, digits 0-9 directly, Backspace/Delete clears. Hover is only a preview; focus stays visible. Name via <label for>, label or aria-label.