Searching Puzzle Pieces

Type to search Puzzle Pieces.

Rating

A star rating in two modes. Read-only display supports half stars; interactive input is an accessible radiogroup with arrow-key navigation and a hover preview. It is controlled — the parent owns value and reads changes back from @change.

Value: 3 of 5

Installation

Copy the piece into your app — it compiles with your build and the code is yours:

puzzle add piece rating

Requires the pieces.css tokens merged into your app styles (see Introduction).

Usage

import Rating from '@/components/ui/Rating.pzl';
<Rating value={ score } size="lg" @change={ setScore } />

Display mode

3.5
4.5

Sizes

Colors

Forms

Posts rating=4

Keyboard

In input mode one star is tabbable (the selected one, else the first); focus it, then:

  • Right / Up arrows — raise the rating by one star
  • Left / Down arrows — lower the rating by one star
  • Home / End — jump to the first or last star
  • Space / Enter — select the focused star

Selected: 2 of 5