Client component

Rating

Star rating. Interactive mode is a radiogroup of native radios (visually hidden), so arrow keys, form participation and announcements come from the platform — selection is whole stars. Display mode (readOnly) renders fractional values like 4.5 as half-filled stars.

Import#

import { Rating } from "astralis-ui";

Read-only display#

readOnly swaps the radios for a static img-role display — this is where fractional averages belong:

4.5 · 1,238 reviews

Sizes#

Props#

PropTypeDefaultDescription
value / defaultValue / onChangenumber / number / (value: number) => void— / 0 / —Controlled / uncontrolled value. Fractions such as 4.5 render only in readOnly mode.
maxnumber5Number of stars.
size"sm" | "md" | "lg""md"Star size.
colorSchemeall 15 schemes"yellow"Hue of the filled stars.
readOnlybooleanfalseStatic display with an img role, including half stars.
disabledbooleanfalseBlocks interaction.
labelstring"Rating"Accessible name of the radio group. Without one, a surrounding Field's label names it.
namestringgeneratedName of the star radios, so the rating submits with a native form.

Keyboard#

The stars are native radios, so the keys are the browser's own:

KeyAction
TabInto the rating: one tab stop, on the selected star
← ↑ / → ↓Select one star fewer / more
SpaceSelect the focused star, when none is selected yet

A readOnly rating is an image, not a control, so it takes no focus.