Skip to content

RatingPro

Capture a numeric opinion: stars as a radio group with half steps, scrubbing, clearing and a value word that rolls.

oxyn add rating
How was this answer?
Great
The code is part of Oxyn Pro

The preview stays free for everyone. Pro opens the code of every Pro component, screen, agent-app template, block and kit, plus the Pro CLI.

Get Pro

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.

Terminal
oxyn add rating

Usage

Dioxus · rust
The code is part of Oxyn Pro

The preview is free. Pro opens the code of every Pro component, screen and template.

Get Pro

Examples

Stars

Five stars with a word.

How was this answer?
Great
Code Pro
The code is part of Oxyn Pro

The preview is free. Pro opens the code of every Pro component, screen and template.

Get Pro

Half

Half steps.

How was this answer?
Great
Code Pro
The code is part of Oxyn Pro

The preview is free. Pro opens the code of every Pro component, screen and template.

Get Pro

Hearts

Hearts (Oxyn plus).

How was this answer?
Great
Code Pro
The code is part of Oxyn Pro

The preview is free. Pro opens the code of every Pro component, screen and template.

Get Pro

Read only

A static image for averages.

How was this answer?Excellent
Code Pro
The code is part of Oxyn Pro

The preview is free. Pro opens the code of every Pro component, screen and template.

Get Pro

API reference

Rating

PropTypeDefaultDescription
labelrequiredString—Label.
valuef32Default::default()Value (0 = not rated).
maxu325Stars.
allow_halfboolDefault::default()Half steps.
allow_clearbooltrueSame value clears.
read_onlyboolDefault::default()Read only.
disabledboolDefault::default()Disabled.
show_valuebooltrueShow the value word.
descriptionOption<String>Default::default()Hint under the stars.
sizeString"md"`sm` · `md` · `lg`.
glyphString"star"`star` · `heart` · `dot`.
labelsVec<String>Default::default()Words per whole star.
on_changeEventHandler<f32>—Committed.

Read from the Rust signature and doc comments.

Keyboard interactions

KeyAction
→ ↑or← ↓Up / down one step
HomeorEndLowest / highest
1–9That many stars
BackspaceorDeleteClear

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
TransitionDurationEasingReduced motion
Fill sweep160 ms + 30 ms staggerease.outinstant
Word roll200 msease.outswap

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 Rating from oxyn_dioxus and include PRIMITIVES_CSS plus the token stylesheet once.
  • A GPUI version exists: RatingEl in oxyn_gpui.
  • Props to set first: label.
  • Keep its states and timings as they ship; restyle it through the CSS variables rather than by hand.

Guides

Oxyn · 74 free components · 264 Pro components · 96 screens · 20 blocks · Dioxus and GPUI