Menu

Rating

Star rating. 6 values × 2 sizes.

4 of 5 for Sylhet green

Installation

$ npx uix-ui@latest add rating

This copies the file into components/ui/rating.tsx in your project. npx shadcn@latest add @uix/rating works too.

Usage

rating.tsx
import { Rating } from "@/components/ui/rating";

<div style={{ display: "grid", gap: 6, justifyItems: "center" }}>
  <Rating aria-label="Rate Sylhet green" value={stars} onValueChange={setStars} />
  <span className="text-body-small text-fg-secondary">{stars} of 5 for Sylhet green</span>
</div>

Props

PropTypeDefaultDescription
sizesm | md"md"
valuenumber0Stars filled, 0 to max.
maxnumber5Number of stars.
onValueChange(value: number) => void–Makes the stars buttons and calls this with the star that was pressed.

Everything else is passed to the root element, so className, aria-* and event handlers work as usual.

Dependencies

Installed for you by the CLI.

  • class-variance-authority
  • clsx
  • tailwind-merge
  • lib/utils.ts
  • components/ui/icons.tsx
esc

↑↓ to navigate · ↵ to select · esc to close