Rating
Star rating component with decimal values, review count, interactive mode and a review card.
How to use it
Run npx @blossomui/react add rating, or copy src/components/UI/Rating/Rating.tsx into your React project and import it.
import { Rating, Review } from './components/ui/Rating'
Props
RatingLabels
| Prop | Type | Description |
|---|
| stars (required) | (value: number, max: number) => string | Accessible name of the stars, for example "3.5 out of 5 stars". |
| star (required) | (star: number) => string | Accessible name of the button of one star. |
| outOf (required) | (value: number, max: number) => string | Text shown with `showValue`. |
| reviews (required) | (count: number) => string | Text shown after the stars with `reviews`. |
RatingProps
| Prop | Type | Description |
|---|
| labels | Partial<RatingLabels> | Texts of the component. Pass only the ones you want to change, for example to translate it. |
| color | string | Color of the filled stars: any CSS color. Gold by default. |
| value (required) | number | Current rating, decimals are supported (3.67). |
| max | number | |
| size | number | Star size in pixels. |
| onChange | (value: number) => void | Makes the stars clickable and called with the chosen value. |
| showValue | boolean | Show "3.67 out of 5". |
| reviews | number | Number of reviews, shown after the stars. |
ReviewProps
| Prop | Type | Description |
|---|
| author (required) | string | |
| rating (required) | number | |
| date (required) | string | |
| children (required) | string | |