About
A star rating component for giving or showing a score, usable as an interactive radio group or a read-only display with fractional star fills.
Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Rating to your project and fits it to your theme.
Code
How Rating is used: the demo's code. The component's own source comes with a free account.
Usage.tsx
import * as React from "react";
import { Rating } from "@/components/ui/rating";
export default function RatingDemo() {
const [score, setScore] = React.useState(3);
return (
<div className="flex flex-col items-center gap-6">
<div className="flex flex-col items-center gap-2">
<span className="text-sm text-muted-foreground">Interactive</span>
<Rating
defaultValue={score}
onValueChange={setScore}
aria-label="Your rating"
/>
</div>
<div className="flex flex-col items-center gap-2">
<span className="text-sm text-muted-foreground">Read-only</span>
<Rating readOnly value={4.5} />
</div>
</div>
);
}
















