Star Rating
poyraz/star-ratingFreeComponent
Poyraz Soft Glass star-rating with semantic states and composable variants.
Install it
npx shadcn@latest add https://ui.poyrazavsever.com/r/star-rating.jsonSource
1import * as React from "react";2import { Star } from "lucide-react";3import { cn } from "@/lib/utils";45interface StarRatingProps extends React.HTMLAttributes<HTMLDivElement> {6 rating: number;7 max?: number;8 label?: string;9}1011function StarRating({ className, label, max = 5, rating, ...props }: StarRatingProps) {12 return (13 <div14 className={cn("flex items-center gap-0.5 text-warning-icon", className)}15 aria-label={label ?? `${rating} out of ${max} stars`}16 {...props}17 >18 {Array.from({ length: max }, (_, index) => (19 <Star20 key={index}21 className={cn(22 "size-3.5",23 index < Math.round(rating) ? "fill-current" : "fill-transparent text-border",24 )}25 aria-hidden="true"26 />27 ))}28 </div>29 );30}3132export { StarRating };33export type { StarRatingProps };
What it pulls in
npm packages
Other registry items
Files it writes
More from poyraz
All 71 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | poyraz | Components | Free | 2 deps | |
| Alertalert | poyraz | Components | Free | 2 deps | |
| Announcement Barannouncement-bar | poyraz | Components | Free | 2 deps | |
| Autocompleteautocomplete | poyraz | Components | Free | 1 dep | |
| Avataravatar | poyraz | Components | Free | 2 deps | |
| Badgebadge | poyraz | Components | Free | 1 dep | |
| Bg Patternbg-pattern | poyraz | Components | Free | no deps | |
| Breadcrumbbreadcrumb | poyraz | Components | Free | 1 dep |
