RatingInput
A star picker for a review form.
View code
<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.
npm add @sdxc/ui remiximport "@sdxc/ui/theme.css";Or copy it into your project to edit it:
sdxc ui add rating-inputUsage
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.
| Prop | Type | Required | Description |
|---|---|---|---|
name | string | Yes | The field the score posts as. |
value | number | No | The score picked now, from 1 to the number of labels. |
required | boolean | No | |
legend | RemixNode | Yes | The question the stars answer, such as "Your rating". |
labels | string[] | Yes | One name per star, lowest first, such as "1 star — Poor"; their count sets the scale. |
Also accepts everything in Omit<TagProps<"fieldset">, "children" | "name">.