Primitives
Rating
Hover previews, click again clears, half steps, word labels; read-only with a count.
Rate your visit · hover to preview, click again to clear
Great
readOnly · with the count
4.6 (128)
3.2 (46)
rating.tsx
"use client";
import { Rating } from "@waveinno/ui";
import * as React from "react";
export default function RatingDemo() {
const [v, setV] = React.useState(4);
return (
<div className="grid gap-6 sm:grid-cols-2">
<div className="flex flex-col items-start gap-3">
<p className="text-[12px] text-muted">Rate your visit · hover to preview, click again to clear</p>
<Rating value={v} onValueChange={setV} size="lg" labels={["Poor", "Fair", "Good", "Great", "Excellent"]} />
<Rating defaultValue={3.5} allowHalf />
<Rating defaultValue={4} icon="heart" />
</div>
<div className="flex flex-col items-start gap-3">
<p className="text-[12px] text-muted">readOnly · with the count</p>
<Rating readOnly value={4.6} count={128} allowHalf />
<Rating readOnly value={3.2} count={46} size="sm" allowHalf />
</div>
</div>
);
}Import#
Everything comes from the package root. The example above uses:
your-component.tsx
import { Rating } from "@waveinno/ui";Props#
Read from the source of this version, so they match the code exactly.
<Rating>
src/components/ui/rating.tsx| Prop | Type | Default | Description |
|---|---|---|---|
value | number | — | |
defaultValue | number | 0 | |
onValueChange | (value: number) => void | — | |
max | number | 5 | |
allowHalf | boolean | false | |
readOnly | boolean | false | |
icon | "star" | "heart" | "star" | |
size | "sm" | "md" | "lg" | "md" | |
labels | string[] | — | One word per whole score, from 1. |
count | number | — | Read-only: the number of ratings behind the score. |
aria-label | string | "Rating" | |
className | string | — |
Install#
If the project does not have the package yet, add it, then follow the setup for Next.js or Vite once.
$ npm install @waveinno/ui