Face Rating

Overview

A five-level rating input where an SVG face morphs between moods.

This rating component is intended for interfaces that need a five-level rating input where an SVG face morphs between moods, feedback forms, and review flows. Its implementation is provided as editable source so the final behavior and styling stay inside your project.

Technologies

React
TypeScript
Tailwind CSS
Motion

Detected package dependencies: framer-motion.

@spectrumui/face-rating

How was your experience?

Hover a segment to preview, click to commit

Installation

Login to view commandCreate a free account to access the install command

Usage

import { FaceRating } from "@/components/spectrumui/face-rating"
<FaceRating onValueChange={(value) => console.log(value)} />

API Reference

FaceRating

Renders a decorative morphing face above a radiogroup of five segment buttons, movable with ArrowLeft and ArrowRight. Pass value to control it from outside, or defaultValue to let it manage its own state.

PropTypeDefaultDescription
valuenumber-Controlled rating from 1-5; 0 means unset. Leave undefined for uncontrolled usage
defaultValuenumber0Initial rating when uncontrolled; 0 means unset
onValueChange(value: number) => void-Fires with the next rating on every commit
labels[string, string, string, string, string]["Terrible", "Bad", "Okay", "Good", "Amazing"]Mood names for levels 1-5, shown under the widget and read to screen readers
showLabelbooleantrueShow the mood label under the segments
size"sm" | "md" | "lg""md"Visual size of the widget (56 / 72 / 96px face)
labelstring"How was your experience?"Accessible name of the radio group
classNamestring-Additional classes merged with the root container styles

Examples

Sizes

Good
Perfect

Use cases

  • interfaces that need a five-level rating input where an SVG face morphs between moods
  • feedback forms
  • review flows

Features

  • Copy-paste source that remains in your repository
  • TypeScript source included with the component
  • Tailwind CSS classes editable in the component source
  • Animation implemented with Motion
  • Responsive Tailwind variants present in the source
  • Reduced-motion handling present in the source

Accessibility

  • The source includes ARIA attributes or roles; preserve them when customizing the component.
  • The source includes keyboard event handling; verify it alongside pointer behavior.
  • The source checks reduced-motion preferences or includes motion-reduce styles.
  • Test focus order, keyboard operation, labels, contrast, and screen-reader output in the final application context.

Customization

  • Edit the Tailwind utility classes in the copied source to match your spacing, color, and typography tokens.
  • Use the documented className surface for local layout adjustments, then edit the source for structural changes.
  • Adjust Motion transitions in the source and keep the reduced-motion behavior aligned with the final interaction.

Topic guides

See how this component fits into broader interface patterns, implementation decisions, and working examples.

Face Rating FAQ

Is Face Rating free to use in commercial projects?

Yes. The public Face Rating source is available under the Apache License 2.0, including for commercial use, subject to the LICENSE terms.

How do I install Face Rating?

Run npx shadcn@latest add @spectrumui/face-rating. The page also exposes the source for manual installation.

Does Face Rating require Motion?

Yes. Motion usage was detected in the documented source or registry dependencies for Face Rating.

Does Face Rating use shadcn/ui or Radix UI?

No shadcn/ui or Radix UI dependency was detected in the documented Face Rating source.

Can I use Face Rating in Next.js?

The documented React source is used in this Next.js application. Keep its use client directive when copying it into the App Router. Install the detected dependencies and verify any application-specific data or image configuration.

What accessibility checks should I run for Face Rating?

The source includes ARIA markup, keyboard handlers, reduced-motion handling. Test the finished interface with keyboard and screen-reader workflows.