---
title: "Star Rating"
description: "A star rating where a new score waves down the row: stars hop and fill in turn, the chosen one pops with sparks, and lowering it drains back."
category: "Micro Interactions"
publishedAt: "2026-11-16"
updatedAt: "2026-11-25"
documentation: "https://beui.dev/micro-interactions/star-rating"
markdown: "https://beui.dev/micro-interactions/star-rating.md"
license: "MIT"
---

# Star Rating

> A star rating where a new score waves down the row: stars hop and fill in turn, the chosen one pops with sparks, and lowering it drains back.

## Install

```bash
npx shadcn@latest add @beui/star-rating
```

## Dependencies

- `clsx`
- `lucide-react`
- `motion`
- `react`
- `tailwind-merge`

## Usage

```tsx
"use client";

import { useState } from "react";
import { StarRating } from "@/components/motion/star-rating";

export function StarRatingUsage() {
  const [rating, setRating] = useState(0);
  return <StarRating value={rating} onValueChange={setRating} size={28} />;
}
```

## API Reference

### StarRating

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `value` | `number` | — | No | Selected stars, 0 for none. |
| `defaultValue` | `number` | `0` | No | The initial rating when uncontrolled. Default: 0 |
| `onValueChange` | `((value: number) => void)` | — | No | Called with the new rating when a star is picked. |
| `max` | `number` | `5` | No | Number of stars. Default: 5 |
| `readOnly` | `boolean` | `false` | No | Shows the value without taking input. |
| `disabled` | `boolean` | `false` | No | Dims the stars and stops input. Default: false |
| `size` | `number` | `20` | No | Star size in pixels. |
| `labels` | `Partial<{ rating: string; star: string; }>` | — | No | Override any built-in string, e.g. for translation. |
| `sound` | `boolean` | `false` | No | Play a select whose pitch rises with the rating. Off by default; a `SoundProvider` can mute it app-wide. |
| `className` | `string` | — | No | Classes merged onto the root element. |

## About Star Rating

Star Rating is a React rating input built with Framer Motion. Hovering lifts the star under the pointer and previews the score in a lighter tint. A new rating sends a wave down the row: each newly lit star hops and fills in turn, and the chosen star lands last with a pop and a burst of sparks. Lowering it drains the stars right to left, and arrow keys move the rating one star at a time. It also works read only for showing an average.

### When to use it

- A review form collects a score.
- A product page shows its rating.
- A feedback widget asks how a session went.

### Accessibility

It is a radio group named Rating with one radio per star, named like "3 of 5 stars". Only the checked star is in the tab order; arrow keys, Home and End change the rating. With reduced motion the fill changes without the sweep or pop.

### FAQ

**Can I change the number of stars?**

Yes. Set max, for example 10.

**How do I show a rating without input?**

Set readOnly. The stars show value and ignore pointer and keyboard input.

## Source

- Registry detail: https://beui.dev/r/star-rating
- Raw source: https://beui.dev/r/star-rating/raw
- GitHub: https://github.com/starc007/ui-components
