Star Rating
Overview
An animated star rating input with hover preview and sparkle burst effects.
This rating component is intended for interfaces that need an animated star rating input with hover preview and sparkle burst effects, feedback forms, and review flows. Its implementation is provided as editable source so the final behavior and styling stay inside your project.
Technologies
Detected package dependencies: framer-motion.
Rate your experience
Hover to preview, click to commit — arrow keys work too
Installation
Usage
import { StarRating } from "@/components/spectrumui/star-rating"<StarRating showValue onValueChange={(value) => console.log(value)} />API Reference
StarRating
Renders a radiogroup of star buttons with full arrow-key, Home/End and Space/Enter keyboard support. Pass value to control it from outside, or defaultValue to let it manage its own state. In readOnly mode it renders a static, fraction-capable display.
| Prop | Type | Default | Description |
|---|---|---|---|
value | number | - | Controlled rating value. Leave undefined for uncontrolled usage |
defaultValue | number | 0 | Initial rating when uncontrolled |
onValueChange | (value: number) => void | - | Fires with the next rating on every commit |
max | number | 5 | Number of stars rendered |
size | "sm" | "md" | "lg" | "md" | Visual size of the stars (16 / 22 / 28 px icons) |
allowClear | boolean | true | Clicking the committed star again clears the rating to 0 |
readOnly | boolean | false | Display-only mode without hover or click interactivity; supports fractional values like 4.3 |
showValue | boolean | false | Show a rolling "4/5" value label that tracks the current or previewed rating |
label | string | "Rating" | Accessible name of the rating group |
className | string | - | Additional classes merged with the default container styles |
Examples
Read-only and sizes
4.3 · based on 1,284 reviews
Use cases
- interfaces that need an animated star rating input with hover preview and sparkle burst effects
- feedback forms
- review flows
Features
- Copy-paste source that remains in your repository
- TypeScript source included with the component
- Tailwind CSS classes editable in the component source
- Animation implemented with Motion
- Responsive Tailwind variants present in the source
- Reduced-motion handling present in the source
Accessibility
- The source includes ARIA attributes or roles; preserve them when customizing the component.
- The source includes keyboard event handling; verify it alongside pointer behavior.
- The source checks reduced-motion preferences or includes motion-reduce styles.
- Test focus order, keyboard operation, labels, contrast, and screen-reader output in the final application context.
Customization
- Edit the Tailwind utility classes in the copied source to match your spacing, color, and typography tokens.
- Use the documented className surface for local layout adjustments, then edit the source for structural changes.
- Adjust Motion transitions in the source and keep the reduced-motion behavior aligned with the final interaction.
Related components
Topic guides
See how this component fits into broader interface patterns, implementation decisions, and working examples.
Star Rating FAQ
Is Star Rating free to use in commercial projects?
Yes. The public Star Rating source is available under the Apache License 2.0, including for commercial use, subject to the LICENSE terms.
How do I install Star Rating?
Run npx shadcn@latest add @spectrumui/star-rating. The page also exposes the source for manual installation.
Does Star Rating require Motion?
Yes. Motion usage was detected in the documented source or registry dependencies for Star Rating.
Does Star Rating use shadcn/ui or Radix UI?
No shadcn/ui or Radix UI dependency was detected in the documented Star Rating source.
Can I use Star Rating in Next.js?
The documented React source is used in this Next.js application. Keep its use client directive when copying it into the App Router. Install the detected dependencies and verify any application-specific data or image configuration.
What accessibility checks should I run for Star Rating?
The source includes ARIA markup, keyboard handlers, reduced-motion handling. Test the finished interface with keyboard and screen-reader workflows.