Skip to main content

Rating

The Rating component provides an interactive star rating system that allows users to view or select a rating value. It's highly customizable with different sizes, colors, and can be set to read-only mode.

Import

import Rating from "@brightcodeui/beta-ui";

Props

PropTypeDefaultDescription
valuenumber0The current rating value
maxnumber5The maximum rating value (number of stars)
readOnlybooleanfalseIf true, the rating cannot be changed
size`"sm""md""lg"`
color`"default""primary""secondary"
onChange(value: number) => voidundefinedCallback function called when the rating changes
classNamestringundefinedAdditional CSS class names

Basic Usage

Different Colors

Read-Only Rating

import { Rating } from "@brightcodeui/beta-ui";

export function ReadOnlyRating() {
return <Rating value={4} readOnly />;
}

Custom Maximum

import { Rating } from "@brightcodeui/beta-ui";

export function TenStarRating() {
return <Rating value={7} max={10} />;
}

Different Sizes

Component API

import Rating from "@brightcodeui/beta-ui";

<Rating
value={3}
max={5}
readOnly={false}
size="md"
color="default"
onChange={(newValue) => console.log(newValue)}
className="my-custom-class"
/>