No.518 · Micro-animations
Star Rate
A five-star rating where the stars light one after another with a pop; five stars throws a sparkle, and a line says what it means.
The prompt
Written for the variant you picked above: Paper
Build a five-star rating as a radiogroup of five star buttons (44px targets, roving tabindex, arrow keys, Home/End). Hovering previews the fill up to the hovered star. Choosing a rating fills the stars one after another — each star pops (scale 1 → 1.35 → 1 while it fills amber, 460ms) with a 70ms stagger — and choosing five also throws eight small sparks out of the last star. A line under the stars says what the rating means ("Not for me" … "Loved it"), announced politely. Two identical pop keyframes alternate per choice so the stagger replays without remounting the buttons (so keyboard focus is kept). Selected variant — Paper (paper): Apply the paper theme. Where the brief above gives no colour values for it, choose a restrained paper palette with text at 4.5:1 contrast or better. Keep the geometry, states and motion described above unchanged. This selection takes precedence over references to other themes or options in the general brief. Implement this selected appearance; do not add a variant picker or alternative appearances unless requested. Implementation requirements: Use React and TypeScript. Keep the component self-contained, with uniquely scoped CSS and no animation libraries. Include required imports, styles and font setup in the result. Interaction: Hover to preview, click or tap to rate; arrow keys move and select when focused. Motion: Star pop 460ms with a 70ms stagger; sparks 700ms on a five-star rating. Accessibility: A radiogroup of labelled radios ("3 stars") with roving tabindex; the meaning line is a polite live region. Reduced motion fills the stars instantly with no sparks. Responsive behavior: A fixed-size control that sits inline wherever it's placed; nothing depends on screen width. Touch: Works the same on touch; there's no hover-only behaviour. Preserve keyboard access, visible focus and reduced-motion behavior. Keep fictional demo data and simulated service calls in a separate usage example; expose callbacks for real actions and recover from rejected requests. Keep usage-example links inside the demo: use local buttons or prevent navigation. Demonstration links must not navigate to Vitrine routes or open other pages; preserve real URL support in the reusable component itself. Verify the result at narrow and wide viewport sizes, with keyboard input and reduced motion enabled.
Notes
- Interaction
- Hover to preview, click or tap to rate; arrow keys move and select when focused.
- Motion
- Star pop 460ms with a 70ms stagger; sparks 700ms on a five-star rating.
- Accessibility
- A radiogroup of labelled radios ("3 stars") with roving tabindex; the meaning line is a polite live region. Reduced motion fills the stars instantly with no sparks.
- Responsive
- A fixed-size control that sits inline wherever it's placed; nothing depends on screen width.
- On touch
- Works the same on touch; there's no hover-only behaviour.