About
An accessible star-rating control with keyboard support, half-star precision, and a hidden form input, for collecting a 1-to-N rating from a user.
Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Rating Group to your project and fits it to your theme.
Code
How Rating Group is used: the demo's code. The component's own source comes with a free account.
Usage.tsx
"use client";
import RatingGroup from "@/components/ui/rating-group";
function Star() {
return (
<svg
viewBox="0 0 24 24"
width={16}
height={16}
fill="currentColor"
aria-hidden="true"
>
<path d="M12 2.5l2.9 6.1 6.7.9-4.9 4.6 1.2 6.6-5.9-3.2-5.9 3.2 1.2-6.6L2.4 9.5l6.7-.9z" />
</svg>
);
}
export default function RatingGroupDemo() {
return (
<div className="flex items-center justify-center p-10">
<RatingGroup.Root defaultValue={3} count={5}>
<RatingGroup.Label>Rating</RatingGroup.Label>
<RatingGroup.Control>
<RatingGroup.Context>
{({ items }: { items: number[] }) =>
items.map((item) => (
<RatingGroup.Item key={item} index={item}>
<Star />
</RatingGroup.Item>
))
}
</RatingGroup.Context>
<RatingGroup.HiddenInput />
</RatingGroup.Control>
</RatingGroup.Root>
</div>
);
}















