Components
Rating Scale
A 0 to 10 scale, like a recommendation score.
<RatingScale legend="How likely are you to recommend us?" />Installation
npx shadcn@latest add https://ui.zjkm.tech/r/rating-scale.jsonimport { RatingScale } from "@/components/rating-scale"Using JavaScript? Set tsx: false in components.json and the CLI converts it.
New to shadcn? Run npx shadcn@latest init first. The CLI needs components.json and the @/ import alias.
Usage
A 0 to 10 scale, as in a recommendation survey, coloured from red to green. The points are native radios, and the two ends carry their labels for screen readers: "0, Not likely".
import { RatingScale } from "@/components/rating-scale";
export function Nps() {
return <RatingScale legend="How likely are you to recommend us?" name="nps" onChange={(n) => record(n)} />;
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
legend | string | The question. | |
min | number | 0 | Lowest point. |
max | number | 10 | Highest point. |
lowLabel | string | "Not likely" | Label for the low end. |
highLabel | string | "Very likely" | Label for the high end. |
name | string | Form field name. | |
onChange | (value: number) => void | Called with the chosen point. | |
className | string | Classes for the fieldset. |
With reduced motion, points don't lift on hover.