Star Rating

Stars that hop and fill in a wave, with sparks on the chosen one.

Preview

"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} />;
}

Install

Add it with the shadcn CLI, or copy the source manually.

$ bunx --bun shadcn add @beui/star-rating

API Reference

value?
number

Selected stars, 0 for none.

Default—
defaultValue?
number

The initial rating when uncontrolled. Default: 0

Default0
onValueChange?
((value: number) => void)

Called with the new rating when a star is picked.

Default—
max?
number

Number of stars. Default: 5

Default5
readOnly?
boolean

Shows the value without taking input.

Defaultfalse
disabled?
boolean

Dims the stars and stops input. Default: false

Defaultfalse
size?
number

Star size in pixels.

Default20
labels?
Partial<{ rating: string; star: string; }>

Override any built-in string, e.g. for translation.

Default—
sound?
boolean

Play a select whose pitch rises with the rating. Off by default; a `SoundProvider` can mute it app-wide.

Defaultfalse
className?
string

Classes merged onto the root element.

Default—

Updated