Skip to content
Sign upPro
Apps SDKRating widgetMenu

Rating widget (Pro)

ProIncluded in $99

Feedback in one tap that invites a little more: stars that name what they mean, or a 0 to 10 scale, then quick reasons and a comment.

ProRate a ride. Move across the stars to see what each means; pick one for quick reasons fitted to it.

Installation

$ pnpm dlx shadcn@latest add @chatcn-pro/rating-widget

Needs chatcn Pro

This command works with a Pro license, along with every Pro component.

Or start free: sign up and get three Pro components on us, with a new one every month.

Usage

tsx
import { RatingWidget } from "@/components/ui/chatcn/pro/rating-widget"

<RatingWidget
  title="Your ride to the airport"
  tags={(v) => (v <= 3 ? ["Late pickup", "Rough driving"] : ["On time", "Smooth driving"])}
  onSubmit={({ value, tags, comment }) => send(value, tags, comment)}
/>

Stars fill as you move across them and the word for each shows beneath, so 3 means Good and not a guess. Picking one brings in quick reasons, which can depend on the rating, and a comment box that grows with its text; switching to a rating whose reasons differ drops the ones that no longer fit. kind="scale" is the 0 to 10 likely to recommend question with both ends named. Sent, it thanks you, keeps the answer and the reasons in a line, and Change reopens it.

Examples

States

ProThe 0 to 10 scale, a rating picked with its reasons, and one already sent.

Props

PropTypeNotes
kind"stars" | "scale"Default stars
title, meta, questionWhat is being rated
tagsstring[] | (value) => string[]Quick reasons
commentbooleanDefault true
defaultValue, defaultSubmittedFor a rating already given
onSubmit({ value, tags, comment }) => voidSends
labelsPartial<RatingWidgetLabels>Every string, including the star words

Keyboard

KeyAction
Arrow keysMove between ratings
SpaceToggle a reason

Accessibility

  • Ratings are a native radio group in a fieldset; each star is named with its number and word.
  • Reasons are toggle buttons; the thanks is announced.

Motion

The hovered star lifts with scale; reasons and the thanks rise in. Reduced motion keeps them still.