Form

Rating

Hand-drawn stars on radio bones. Hover previews, arrows adjust, nothing is a div pretending.

You gave it 3 of 5. The marigolds are flattered.

Garden club average
Show code
"use client";

import { useState } from "react";

import { Rating } from "@/registry/lilt/ui/rating";

export default function RatingDemo() {
  const [stars, setStars] = useState(3);

  return (
    <div className="flex w-full max-w-xs flex-col gap-6">
      <div className="flex flex-col gap-1.5">
        <Rating
          label="Rate this seed packet"
          onValueChange={setStars}
          value={stars}
        />
        <p className="text-sm text-[var(--lilt-text-muted)]">
          You gave it {stars} of 5. The marigolds are flattered.
        </p>
      </div>
      <div className="flex flex-col gap-1.5">
        <span className="font-display text-xs font-bold uppercase tracking-[0.15em] text-[var(--lilt-text-muted)]">
          Garden club average
        </span>
        <Rating readOnly value={4} />
      </div>
    </div>
  );
}

Installation

npx shadcn@latest add @lilt/rating

Accessibility

  • Each star is a real radio labelled '1 star' through '5 stars' — one Tab stop, arrow keys adjust.
  • readOnly mode renders role='img' named 'N of 5 stars'; the star glyphs themselves are decorative.