HalfStarRating

Half-star ratings. Point at the left half of a star for a half, the right for a whole; stars ripple up to your choice when you press. Inputs.

Open playground

About

HalfStarRating is a React component in the Inputs category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { HalfStarRating } from "@ashutoshswamy/smoui" and set showValue, value, onChange among its 6 props.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
import { HalfStarRating } from "@ashutoshswamy/smoui";

<HalfStarRating defaultValue={3.5} onChange={setRating} />

Props 6

showValue

Show the number beside the stars, rolling as it changes.

boolean
value / defaultValue

Controlled or initial half-step rating.

numberdefault 0
onChange

Called on selection.

(value: number) => void
count

Maximum stars.

numberdefault 5
size

Star size in px.

numberdefault 28
label

Accessible slider name.

stringdefault "Rating"