Code

<!-- nova-rating.free.js: download it from the Install section below and host it with your site -->
<script src="/nova-rating.free.js" defer></script>

<nova-rating
  value="3"
  max="5"
  size="48"
  theme="light"
  label="Rate this stay"
></nova-rating>

<script>
  document.querySelector('nova-rating').addEventListener('change', (e) => {
    console.log(e.detail.value);
  });
</script>

In context

How was your stay at Casa Olmo?
Tap a star
Feedback prompt
Casa Olmo
4.7 (1,204)
Hotel Vessel
4.2 (386)
The Tin Roof
3.4 (92)
Average scores, Aurora and Mint Pro

Install · Free Web Component

One file, no dependencies. Solar preset, every other option included. Host it yourself so your visitors never load anything from our servers.

1. Install with one command — or download the file
shadcn CLI · React
npx shadcn@latest add https://www.ui-design.co/r/nova-rating.json
2. Load it and use the element
HTML
<!-- nova-rating.free.js: download it from the Install section below and host it with your site -->
<script src="/nova-rating.free.js" defer></script>

<nova-rating
  value="4"
  max="5"
  size="34"
  theme="light"
  label="Rate this stay"
></nova-rating>

<script>
  document.querySelector('nova-rating').addEventListener('change', (e) => {
    console.log(e.detail.value);
  });
</script>
3. React + TypeScript (optional)

The shadcn command adds a typed React wrapper for you. Using the file directly? Custom elements work in React as-is; for type checking add:

TypeScript
// nova-rating.d.ts
declare namespace JSX {
  interface IntrinsicElements {
    'nova-rating': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
      value?: number | string;
      max?: number | string;
      step?: number | string;
      size?: number | string;
      readonly?: boolean | '';
      disabled?: boolean | '';
      theme?: 'light' | 'dark';
      label?: string;
      sound?: boolean | '';
    };
  }
}

Pro · React + TypeScript Pro

One payment of $4.99, yours forever. Use it in unlimited personal and commercial projects; no resale.

  • React component (controlled or uncontrolled) with TypeScript types and the full source
  • Aurora, Mint and Mono tints, plus your own three colours as a custom tint
  • The vanilla Web Component with every tint, a demo page, README and license

Attributes & props

NameTypeDefaultDescription
value number0The rating. Fires change with detail.value. Tapping the current rating again clears it to 0.
max number5Number of stars (1–10).
step 1 | 0.51Whole stars or halves.
size number (px)34Star size; the gap scales with it.
readonly booleanoffShows a score and ignores input. Any fraction works here: 4.3 fills 30% of the fifth star. readOnly in React.
disabled booleanoffDims it and ignores input.
theme 'light' | 'dark''light'Empty stars pressed into a light or a dark surface.
label string'Rating'Accessible name. aria-label in React.
sound booleanoffA glass clink, higher for a higher rating (plus a tap of vibration on phones). Also on for everything inside an element with data-ui-sound="on".
tint Pro'solar' | 'aurora' | 'mint' | 'mono' | object'solar'Colours across the row, or a custom { colors: [a, b, c] }. Free build ships Solar only.

On a phone you can tap a star or drag across the row and lift. From the keyboard the arrow keys change the rating by one step, Home clears it, End gives the maximum and the digit keys set it directly. The stars are CSS masks and the sparks are a handful of short-lived elements — no canvas, no WebGL — so dozens of read-only ratings in a list are fine. Reduced motion keeps the fill and drops the hop and the sparks.

More components