RatingPro
Capture a numeric opinion: stars as a radio group with half steps, scrubbing, clearing and a value word that rolls.
oxyn add ratingThe preview stays free for everyone. Pro opens the code of every Pro component, screen, agent-app template, block and kit, plus the Pro CLI.
Rendered from Rust at build time · goes live when visible
When to use
- Rate an answer, a run or a tool; show an average read-only.
When not to use
- Feedback on a reply: use Response feedback instead.
- On or off for things that apply right away: use Switch instead.
- A real checkbox with a label and second line, an indeterminate state for Select all, an error, a card row and a check that draws itself: use Checkbox instead.
Installation
Rating is part of Oxyn Pro; the preview is free. Pro items install with the oxyn CLI once your licence is signed in; until then Pro members copy the code from this page.
oxyn add ratingUsage
The preview is free. Pro opens the code of every Pro component, screen and template.
Examples
Stars
Five stars with a word.
Code Pro
The preview is free. Pro opens the code of every Pro component, screen and template.
Half
Half steps.
Code Pro
The preview is free. Pro opens the code of every Pro component, screen and template.
Hearts
Hearts (Oxyn plus).
Code Pro
The preview is free. Pro opens the code of every Pro component, screen and template.
Read only
A static image for averages.
Code Pro
The preview is free. Pro opens the code of every Pro component, screen and template.
API reference
Rating
| Prop | Type | Default | Description |
|---|---|---|---|
labelrequired | String | — | Label. |
value | f32 | Default::default() | Value (0 = not rated). |
max | u32 | 5 | Stars. |
allow_half | bool | Default::default() | Half steps. |
allow_clear | bool | true | Same value clears. |
read_only | bool | Default::default() | Read only. |
disabled | bool | Default::default() | Disabled. |
show_value | bool | true | Show the value word. |
description | Option<String> | Default::default() | Hint under the stars. |
size | String | "md" | `sm` · `md` · `lg`. |
glyph | String | "star" | `star` · `heart` · `dot`. |
labels | Vec<String> | Default::default() | Words per whole star. |
on_change | EventHandler<f32> | — | Committed. |
Read from the Rust signature and doc comments.
Keyboard interactions
| Key | Action |
|---|---|
| → ↑or← ↓ | Up / down one step |
| HomeorEnd | Lowest / highest |
| 1–9 | That many stars |
| BackspaceorDelete | Clear |
Accessibility
- radiogroup with one radio per step labelled “Great, 4 of 5 stars”; commits announced politely.
- Read-only renders role=img with an aria-label.
From the spec
One radio per whole star labelled “Great, 4 of 5 stars”; commits announced politely; read-only is an image with a label.
Motion & interaction
Fill sweeps star by star with a 30 ms stagger; pressed stars dip to 0.86; the value word rolls in the direction of change.
Timing
| Transition | Duration | Easing | Reduced motion |
|---|---|---|---|
| Fill sweep | 160 ms + 30 ms stagger | ease.out | instant |
| Word roll | 200 ms | ease.out | swap |
Responsive behaviour
- 36 px touch cells; the word wraps under the stars when space runs out.
Edge cases (spec)
0 means not rated; allow_clear: false keeps at least one step. Half stars come from the left half of a star.
Notes for AI
- Import
Ratingfromoxyn_dioxusand includePRIMITIVES_CSSplus the token stylesheet once. - A GPUI version exists:
RatingElinoxyn_gpui. - Props to set first:
label. - Keep its states and timings as they ship; restyle it through the CSS variables rather than by hand.