SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

On this page

RatingInput

A star picker for a review form.

How would you rate this print?
View code
tsx
<form method="post" action="/reviews">
	<RatingInput
		name="rating"
		legend="How would you rate this print?"
		value={4}
		required
		labels={["1 star — Poor", "2 stars — Fair", "3 stars — Good", "4 stars — Great", "5 stars — Excellent"]}
	/>
</form>

Installation

An ordinary dependency: install it, import the theme once, and import the component where it is used.

Terminal
npm add @sdxc/ui remix
typescript
import "@sdxc/ui/theme.css";

Or copy it into your project to edit it:

Terminal
sdxc ui add rating-input

Usage

typescript
import { RatingInput } from "@sdxc/ui";

Renders one radio and its star label per entry of labels, in score order so the native arrow keys step up and down the scale. A star fills when its own radio or any later one is checked, and hovering a star fills it and every earlier one in place of the checked score.

Props

Read from the component's own types, so every prop, every default and every allowed value is listed.

PropTypeRequiredDescription
namestringYesThe field the score posts as.
valuenumberNoThe score picked now, from 1 to the number of labels.
requiredbooleanNo
legendRemixNodeYesThe question the stars answer, such as "Your rating".
labelsstring[]YesOne name per star, lowest first, such as "1 star — Poor"; their count sets the scale.

Also accepts everything in Omit<TagProps<"fieldset">, "children" | "name">.

@sdxc/ui

Can’t find it? Contact us