Componentform0.91 KB gzipZero dependencies

Rating

Interactive star rating with live hover preview.

Preview

Live Preview
Open ↗

Installation

Tokens guide →

Add to your project via CLI (zero dependencies, code you own):

npx bigbullui add rating

Or install the full npm package:

npm install bigbullui

Usage

tsx3 lines
import { Rating } from "@/components/ui/rating"; <Rating defaultValue={4} max={5} />

Source code

rating.tsx + 1 helper

Zero third-party dependencies (2 local files shown in tabs below).

tsxrating.tsx105 lines
"use client"; import * as React from "react";import { cn } from "./lib/utils"; export interface RatingProps extends Omit<React.HTMLAttributes<HTMLElement>, "value" | "defaultValue"> {  value?: number;  defaultValue?: number;  max?: number;  onValueChange?: (value: number) => void;  disabled?: boolean;  className?: string;  "aria-label"?: string;} export function Rating({  value: controlledValue,  defaultValue = 0,

Props

Interactive Prop Playground

Tweak parsed AST props below to generate ready-to-paste JSX.

tsx3 lines
import { Rating } from "@/components/ui/rating"; <Rating />
PropTypeDescription
valuenumberControlled value.
defaultValuenumberInitial value when uncontrolled. (Default: 0)
maxnumberMaximum allowed numeric or date bound. (Default: 5)
onValueChange(value: number) => voidCallback invoked on value change.
disabledbooleanDisables interaction and applies disabled styling. (Default: false)
classNamestringOptional Tailwind or custom CSS classes merged with component styles.
aria-labelstringConfigures aria label.