ComponentsEssentials
Rating
Captures user sentiment in four patterns — star scale, numeric NPS scale, emoji reaction picker, and binary thumbs — with full intent palette, half-star precision, RTL support, and keyboard navigation.
Playground
Installation
pnpm add @tessinaui/uiUsage
import { Rating } from "@tessinaui/ui";{/* Star (default) */}
<Rating defaultValue={4} />
{/* Half-star */}
<Rating precision={0.5} defaultValue={3.5} />
{/* NPS numeric scale */}
<Rating variant="numeric" max={10} showLabel lowLabel="Not likely" highLabel="Extremely likely" />
{/* Emoji reactions */}
<Rating variant="reaction" showLabel />
{/* Binary thumbs */}
<Rating variant="binary" />Showcase
Variants
| Variant | Pattern | Use case |
|---|---|---|
star | ★★★★☆ | Product ratings, review scores |
numeric | 1 2 3 … 10 | NPS, customer satisfaction (CSAT) |
reaction | 😡 😕 😐 🙂 😄 | App feedback, quick sentiment |
binary | 👎 👍 | Helpful / not helpful, like |
API Reference
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "star" | "numeric" | "reaction" | "binary" | "star" | Visual pattern |
value | number | null | — | Controlled value (null = nothing selected) |
defaultValue | number | null | null | Uncontrolled initial value |
onChange | (value: number | null) => void | — | Called when the value changes |
max | number | 5 (star) / 10 (numeric) | Number of stars or scale buttons |
size | "xs" | "sm" | "md" | "lg" | "xl" | "md" | Size token |
intent | "none" | "warning" | "primary" | "error" | "success" | "info" | "warning" (star) / "primary" (others) | Colour intent |
readOnly | boolean | false | Prevent interaction, render current value |
disabled | boolean | false | Prevent interaction, reduce opacity |
precision | 1 | 0.5 | 1 | Star variant only — 0.5 enables half-star selection |
allowClear | boolean | false | Allow clicking the active value to deselect |
dir | "ltr" | "rtl" | "ltr" | Text direction — reverses star order and half-star clip anchor |
icon | ReactNode | — | Star variant — custom filled icon |
emptyIcon | ReactNode | — | Star variant — custom empty icon |
items | RatingItem[] | built-in | Reaction/binary — custom option list |
showLabel | boolean | false | Star: shows 3 / 5. Numeric: shows endpoint labels. Reaction/binary: shows selected item label |
lowLabel | string | — | Numeric — left endpoint label (visible when showLabel is true) |
highLabel | string | — | Numeric — right endpoint label (visible when showLabel is true) |
label | string | — | Accessible aria-label on the radiogroup |
className | string | — | Additional classes on the root element |
RatingItem
Used by items prop for the reaction and binary variants.
| Field | Type | Description |
|---|---|---|
value | number | Unique option value |
label | string | Button label and accessible name |
icon | ReactNode | Optional icon rendered before the label |
Notes
- Accessibility — The root renders
role="radiogroup"and each option rendersrole="radio"witharia-checked. Screen readers announce the selection correctly without additional ARIA configuration. - Keyboard navigation (star) — Arrow keys step by
precision(1 or 0.5).Homeselects the minimum,Endthe maximum,Delete/Backspaceclears whenallowClearis true. - Half-star display — A value of
3.5renders the fourth star half-filled using anoverflow-hiddenclip span. The clip anchor (left: 0vsright: 0) flips automatically for RTL. - Custom icons — Any
ReactNodeworks asicon/emptyIcon. Size is inherited from the button's width — use the same icon class (size-6formd) to keep alignment. - RTL —
dir="rtl"reverses the star row viaflex-row-reverseand mirrors the half-star fill anchor. Reaction and binary variants inherit RTL from thedirprop on the root. - Controlled vs uncontrolled — Pass
value+onChangefor controlled, ordefaultValuealone for uncontrolled. The two modes are mutually exclusive — oncevalueis defined the component is fully controlled.
Meter
Gauge displaying a known value within a fixed range — battery, disk usage, score, capacity. Linear or circular, four sizes, full intent palette with optional threshold-based auto-coloring, locale-aware formatting, and a multi-segment MeterGroup variant for stacked usage.
Label
A foundational form label primitive. Five sizes, five intents, three tones, three weights, required/optional indicators, leading/trailing icons, optional description, and RTL support.