Skip to Content
zjkm-ui
Components

Rating Scale

A 0 to 10 scale, like a recommendation score.

How likely are you to recommend zjkm-ui to a friend?
Props
<RatingScale legend="How likely are you to recommend us?" />

Installation

npx shadcn@latest add https://ui.zjkm.tech/r/rating-scale.json
import { 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

PropTypeDefaultDescription
legendstringThe question.
minnumber0Lowest point.
maxnumber10Highest point.
lowLabelstring"Not likely"Label for the low end.
highLabelstring"Very likely"Label for the high end.
namestringForm field name.
onChange(value: number) => voidCalled with the chosen point.
classNamestringClasses for the fieldset.

With reduced motion, points don't lift on hover.

On this page