Ayushmaan Singh

Star Rating

Forms 77

About

A customizable star rating component that allows users to rate with interactive star icons.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Star Rating to your project and fits it to your theme.

Code

How Star Rating is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

import { StarRating } from "@/components/ui/star-rating"


function DefaultRating() {
  return (
    <div className="space-y-2 text-center">
      <StarRating 
        defaultValue={3}
        onRate={(rating) => console.log(`Rated: ${rating}`)}
      />
    </div>
  )
}

function SmallRating() {
  return (
    <div className="space-y-2 text-center">
      <h3 className="font-medium">Small Rating</h3>
      <StarRating 
        size="sm"
        onRate={(rating) => console.log(`Rated: ${rating}`)}
      />
    </div>
  )
}

function LargeRating() {
  return (
    <div className="space-y-2 text-center">
      <h3 className="font-medium">Large Rating</h3>
      <StarRating 
        size="lg"
        totalStars={10}
        onRate={(rating) => console.log(`Rated: ${rating}`)}
      />
    </div>
  )
}

function DisabledRating() {
  return (
    <div className="space-y-2 text-center">
      <h3 className="font-medium">Disabled Rating</h3>
      <StarRating 
        defaultValue={4}
        disabled
      />
    </div>
  )
}

export { DefaultRating, SmallRating, LargeRating, DisabledRating }

Dependencies

More by Ayushmaan Singh

View all
  • Tubelight Navbar

    Tubelight Navbar

    3.6K
  • Theme Toggle

    Theme Toggle

    2.5K
  • Feature Section

    Feature Section

    1.7K
  • Vintage Keyboard

    Vintage Keyboard

    570
  • Thumbnail Carousel

    Thumbnail Carousel

    409
  • Typewriter Testimonial

    Typewriter Testimonial

    318
  • Image Fan Carousel

    Image Fan Carousel

    283
  • Testimonials

    Testimonials

    245

More in Forms

View all
  • Premium Auth

    Premium Auth

    500
  • Login 1

    Login 1

    52
  • Book A Demo 3

    Book A Demo 3

    83
  • Authentication Card

    Authentication Card

    47
  • Contact Card

    Contact Card

    1K
  • Login Card

    Login Card

    32
  • Book A Demo 1

    Book A Demo 1

    69
  • Login 2

    Login 2

    7