Skip to content
Vertical Jump Designs-uiFront-End Studio
Get Pro

v3.9 is out.

Forms

RatingScale

Free13.0 KB gzipped

A labeled, single-choice rating scale: faces, numbers (such as a 0 to 10 likelihood scale), or thumbs up and down. Unlike Rating, each option is its own choice with its own name, so choosing one never fills the others. Built on native radios in a role="radiogroup": Tab lands on the selected option, arrow keys move and select, and the value submits with a form.

Accessibility: WCAG 2.2 AA · No A or AA violations in light or dark mode · Keys: Tab, Arrow keys, Space and 2 more · Full report

Import

tsx
import { RatingScale } from "@vjdesigns/vjdesigns-ui";

Importing only RatingScale adds about 13.0 KB of minified, gzipped JavaScript to your app (React not included). The stylesheet is shared by every component and loaded once: 75.1 KB gzipped.

Examples

Basic

Five faces, from very unhappy to very happy. Each face is its own native radio with its own name, so choosing one never fills the others (unlike Rating). sentiment tints them from red to green; the shapes already carry the meaning, so color is never the only cue.

How was your first practice?
tsx
import { RatingScale } from "@vjdesigns/vjdesigns-ui";

export function Basic() {
  return (
    <RatingScale variant="faces" label="How was your first practice?" showLabels sentiment defaultValue={4} />
  );
}

Numbers

numbers runs from min to max, such as the 0 to 10 "how likely" question. startLabel and endLabel caption the ends and are read as part of the description.

How likely are you to recommend the league to a friend?
Not likelyVery likely

Score: none yet

tsx
import { useState } from "react";
import { RatingScale, Stack, Text } from "@vjdesigns/vjdesigns-ui";

export function Numbers() {
  const [value, setValue] = useState<number | null>(null);
  return (
    <Stack gap={3} style={{ width: "100%", maxWidth: "40rem" }}>
      <RatingScale
        variant="numbers"
        min={0}
        max={10}
        label="How likely are you to recommend the league to a friend?"
        startLabel="Not likely"
        endLabel="Very likely"
        value={value}
        onValueChange={setValue}
      />
      <Text tone="muted">Score: {value ?? "none yet"}</Text>
    </Stack>
  );
}

Thumbs

thumbs is a two-choice scale for quick yes or no feedback. showLabels puts each option's name under it.

Was this article helpful?
tsx
import { RatingScale } from "@vjdesigns/vjdesigns-ui";

export function Thumbs() {
  return <RatingScale variant="thumbs" label="Was this article helpful?" showLabels />;
}

In aform

Inside a Field, the scale takes the field's label, hint, error and required, and its value submits with the form like any radio group.

1 is poor, 5 is excellent.

tsx
import { useState } from "react";
import {
  Button,
  Field,
  RatingScale,
  Stack,
  Text,
} from "@vjdesigns/vjdesigns-ui";

export function InAForm() {
  const [value, setValue] = useState<number | null>(null);
  const [submitted, setSubmitted] = useState(false);
  const missing = submitted && value === null;
  return (
    <form
      noValidate
      onSubmit={(event) => {
        event.preventDefault();
        setSubmitted(true);
      }}
      style={{ width: "100%", maxWidth: "30rem" }}
    >
      <Stack gap={4} align="start">
        <Field
          label="Rate the coaching"
          hint="1 is poor, 5 is excellent."
          required
          error={missing ? "Choose a rating." : undefined}
        >
          <RatingScale variant="numbers" name="coaching" value={value} onValueChange={setValue} />
        </Field>
        <Button type="submit">Send feedback</Button>
        {submitted && value !== null && <Text tone="muted">Thanks! You rated the coaching {value} out of 5.</Text>}
      </Stack>
    </form>
  );
}

Clear and read only

allowClear lets people take back their choice: press the selected option again, or press Delete. readOnly shows a saved rating as one image named "Rated: Happy".

Your mood today (you can clear it)
Press Space on the selected rating, or Delete, to clear it.
Last week's rating
tsx
import { RatingScale, Stack } from "@vjdesigns/vjdesigns-ui";

export function ClearAndReadOnly() {
  return (
    <Stack gap={5}>
      <RatingScale variant="faces" label="Your mood today (you can clear it)" allowClear defaultValue={3} />
      <RatingScale variant="faces" label="Last week's rating" readOnly defaultValue={4} />
    </Stack>
  );
}

Sizes and states

size is sm, md or lg. disabled turns off every option.

Small
Large
Disabled
tsx
import { RatingScale, Stack } from "@vjdesigns/vjdesigns-ui";

export function SizesAndStates() {
  return (
    <Stack gap={4}>
      <RatingScale variant="numbers" size="sm" label="Small" defaultValue={2} />
      <RatingScale variant="numbers" size="lg" label="Large" defaultValue={4} />
      <RatingScale variant="thumbs" label="Disabled" disabled defaultValue={1} />
    </Stack>
  );
}

Right to left

The first example again, inside a right-to-left LocaleProvider (Arabic). Layout, spacing and arrow icons mirror, and the components' built-in text is translated. The example's own text stays in English.

Basic

How was your first practice?
tsx
import { LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import ar from "@vjdesigns/vjdesigns-ui/locales/ar";

// Basic is the "Basic" example above.
<LocaleProvider locale="ar" messages={ar}>
  <Basic />
</LocaleProvider>

API reference

RatingScale

New in 3.8.4
RatingScale props
PropTypeDefault
variant

Look and built-in options: five faces (very unhappy to very happy), numbers from min to max (e.g. a 0 to 10 likelihood scale), or thumbs up (1) and down (0).

"faces""numbers""thumbs""numbers"
value

Selected value (controlled). null means nothing is selected. Use with onValueChange.

number | null—
defaultValue

Initial value (uncontrolled).

number | nullnull
onValueChange

Called with the selected value, or null when cleared.

(value: number | null) => void—
min

numbers only: the lowest value.

number1
max

numbers only: the highest value.

number5
options

Custom options, replacing the variant's built-in set (and min / max). The variant still sets the look.

RatingScaleOption[]—
startLabel

Caption under the first option, e.g. "Not likely". Also read as part of the description.

ReactNode—
endLabel

Caption under the last option, e.g. "Very likely". Also read as part of the description.

ReactNode—
showLabels

Show each option's label under it (faces and thumbs).

booleanfalse
sentiment

faces only: tint the faces from danger (lowest) to success (highest). The face shapes already carry the meaning; the tint is extra.

booleanfalse
size

Option size. Falls back to a surrounding Field's size.

"sm""md""lg""md"
allowClear

Let the user remove their choice: clicking (or pressing Space on) the selected option again, or pressing Delete / Backspace, resets it to null.

boolean—
clearHint

Instructions announced with each option when allowClear is on. Localize it here.

string"Press Space on the selected rating, or Delete, to clear it."
disabled

Disables every option. Falls back to a surrounding Field's state.

boolean—
readOnly

Show the value without allowing changes: a single role="img" named "Rated: Happy", plus a hidden input so the value still submits when name is set.

boolean—
invalid

Marks the scale invalid: danger outlines and aria-invalid. Falls back to a surrounding Field's state.

boolean—
required

A choice is required: sets native required on the radios. Falls back to a surrounding Field's state.

boolean—
name

Shared name for the native radios (used in form submission). Generated with useId when omitted.

string—
getReadOnlyLabel

Read-only: accessible name. Localize it here.

(option: RatingScaleOption) => string"Rated: Happy"
unratedLabel

Read-only with no value: accessible name.

string"Not rated"
label

Visible label, used when the scale stands alone. Ignored inside a Field/Fieldset, whose label or legend names it. Without a label, pass aria-label or aria-labelledby.

ReactNode—
description

Help text under the label, linked with aria-describedby.

ReactNode—

Also accepts native <div> attributes, plus className, style and ref.

See what changed in each version in the Changelog.

Accessibility report

RatingScale targets WCAG 2.2 AA. Below: a live axe-core audit of this page's examples, Lighthouse scores for the page in both modes, the accessibility behavior built into the component, and the checks only a person can do.

axe-core audit (live)

Running accessibility audit

Checking the examples above…

Lighthouse audit

Light mode

Score 100

36 passed · 0 failed · 29 not applicable · 10 to check by hand

Dark mode

Score 100

36 passed · 0 failed · 29 not applicable · 10 to check by hand

Lighthouse 13.5.0 audits the whole docs page (header and sidebar included), not just the examples, in English. Last run 11/27/2026. Some failed audits carry no weight in the score, so a page can score 100 and still list one.

Built-in behavior

Keyboard

Keyboard
KeyAction
TabMoves into the scale, on the selected option (or the first), and out of it. The scale is one Tab stop.
Arrow keysMoves to the next or previous option and selects it, as in any native radio group.
SpaceSelects the focused option; with allowClear, on the selected option it clears the choice.
DeleteBackspaceWith allowClear: clears the choice.

Built on native radios, so the value submits with a form and works with Field and useFormValidation. Each option is its own choice with its own name, so choosing one never fills the others.

Roles and states

Roles and states
ElementRoleStates and properties
Scaleradiogrouparia-labelledby (the label or Field), aria-describedby (description and the startLabel / endLabel captions), aria-required, aria-disabled
Option <input type="radio">radioaria-label ("Happy", "7"), aria-describedby (the clear hint, with allowClear), aria-invalid in a Fieldset
Face, number or thumbnonearia-hidden; shapes and text tell options apart, never color alone
Read-only scaleimgaria-label ("Rated: Happy", or "Not rated")

Manual checks

Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.

Manual accessibility checks
CheckWhat to testWCAG 2.2
KeyboardEvery action works with Tab, Shift+Tab, Enter, Space and the arrow keys, and focus never gets stuck.2.1.1 (A), 2.1.2 (A)
FocusFocus moves in a logical order, is always visible, and isn't hidden behind sticky headers.2.4.3 (A), 2.4.7 (AA), 2.4.11 (AA), 2.4.13 (AAA)
Screen readersNames, roles and states are announced correctly, and status changes are announced without moving focus.1.3.1 (A), 4.1.2 (A), 4.1.3 (AA)
ColorMeaning never depends on color alone; your own colors meet contrast in both modes.1.4.1 (A), 1.4.3 (AA), 1.4.11 (AA), 1.4.6 (AAA)
Zoom and reflowAt 200% text size and at 320px wide (400% zoom), nothing is cut off and no sideways scrolling is needed.1.4.4 (AA), 1.4.10 (AA), 1.4.12 (AA)
Pointer targetsClick and tap targets are at least 24×24px (44×44px for AAA), or spaced so they don't overlap.2.5.8 (AA), 2.5.5 (AAA)
MotionAnimations respect the reduced-motion setting.2.3.3 (AAA)