Skip to content

Rating ​

Use rating when a person chooses a score from a short, ordered scale, or scores several related dimensions. It supports three presentations:

  • numeric renders the values as selectable pills.
  • radio renders conventional radio controls with numeric labels or custom labels for ordered grades.
  • radio-matrix renders several semantic-differential radio rows against one shared numeric scale.

All modes adapt to the width available to the component. Numeric rating options share the full container width equally and can grow beyond 80px. Below 768px, numeric ratings place the endpoint text above the values, while radio and radio-matrix ratings become vertical lists.

Intent colouring ​

Numeric ratings are neutral by default. For a semantic scale, pass inclusive intentRanges for danger, warning, and success. Values outside those intervals stay neutral, and the element warns in the console when that happens, so partial coverage doesn't go unnoticed.

Live example ​

  • Radio Group — for unrelated choices rather than ordered grades
  • Range Input — for a continuous or finely stepped value

Guidelines ​

When to use ​

Use a rating for a short, ordered numeric scale where each value is a discrete choice. Use radio mode when conventional form affordance is more important; use numeric mode when the score itself should be the strongest visual element.

Use named radio choices only when their labels describe ordered grades of the same question. For unrelated categories, use Radio Group. For continuous values or large ranges, use Range Input.

Scale and step ​

min and max set the ends of the scale, and step sets the gap between values, counting up from min. Pick a step that divides the range evenly so the last value is max: with min="1", max="10", and step="4", the scale is 1, 5, 9, and the element warns in the console. Remember that min defaults to 1: step="5" with max="20" gives 1, 6, 11, 16 unless you also set min. Keep the number of values small; a stepped scale is still one choice per value.

vue
<catnip-rating .min="0" .max="100" .step="10" start-text="Not at all likely" end-text="Extremely likely" />

Align intentRanges with the generated values; the console warns about a range that reaches past the scale, contains no value on it, or leaves values without an intent. In radio-matrix mode, a row only counts as answered when its value is on the scale.

Colouring ​

Keep all values neutral unless the colour communicates a stable meaning that is explained by the surrounding question or content.

For a segmented scale, bind inclusive intervals:

vue
<catnip-rating
  .min="0"
  .max="6"
  .intentRanges="{
    danger: { from: 0, to: 2 },
    warning: { from: 3, to: 4 },
    success: { from: 5, to: 6 }
  }"
/>

Avoid overlapping ranges. The deterministic fallback is danger, then warning, then success.

Named radio choices ​

Radio mode generates numbered choices from min through max by default. Pass a nonempty radioOptions array to show a label for each grade or add a nonnumeric choice such as N/A. Its entries determine the choices and their order; min and max no longer apply to those radio choices. Omit radioOptions or pass [] to restore the numbered range. In the live example, clearing the radioOptions editor also restores that range. The value is emitted unchanged, so modelValue may be a string in radio mode.

vue
<catnip-rating
  mode="radio"
  label="How well does the product meet your needs?"
  .radioOptions="[
    { value: 0, label: 'Not at all' },
    { value: 1, label: 'Slightly' },
    { value: 2, label: 'Partly' },
    { value: 3, label: 'Neutral' },
    { value: 4, label: 'Mostly' },
    { value: 5, label: 'Extremely well' },
    { value: 'na', label: 'N/A' }
  ]"
  .modelValue="rating"
  @update:modelValue="rating = $event.detail[0] ?? $event.detail"
/>

Use distinct values and labels. Without radioOptions, radio mode still shows the numeric grades.

Radio-matrix ratings ​

Use mode="radio-matrix" for multiple semantic-differential rows sharing the same grades. Supply the row endpoints through rows; modelValue contains one selected number (or null) per row in the same order.

Keep rows and modelValue aligned when questions change. If you reorder rows, reorder their answers in the same update; if you replace a question, clear its answer. The docs playground clears all answers when its rows change because the row data has no stable identifier to remap them safely.

vue
<catnip-rating
  mode="radio-matrix"
  .required="true"
  label="How would you rate your overall experience with our support team?"
  description="1: Lowest score | 5: Highest score"
  .rows="[
    { startText: 'Slow', endText: 'Fast' },
    { startText: 'Unhelpful', endText: 'Helpful' }
  ]"
  .modelValue="ratings"
  @update:modelValue="ratings = $event.detail[0]"
  @completion-change="completion = $event.detail[0]"
/>

completion-change fires when radio-matrix completion or required validity changes, including on the initial render. Its detail is { complete, valid, unansweredRows }; unansweredRows contains zero-based row indexes. When required is true, valid is false until every row has an in-range answer. A score of 0 counts as answered.

Labels and endpoints ​

  • Ask one clear question in label.
  • Use description for context, not validation copy.
  • Use startText and endText to explain what the lowest and highest scores mean.
  • Do not rely on colour alone; numeric and radio-matrix choices include their scores, while custom radio choices need meaningful text labels.

Supporting text and errors ​

Use supportingText for helper or validation copy below the whole rating. Set intent="danger" when consumer validation finds the rating invalid; this colours the supporting text and exposes aria-invalid on the radiogroups. The supporting text accepts the same string, array, and { text, intent?, icon? } message forms as other fields.

For a required radio matrix, use completion-change to build a specific message such as “Please rate the 2 remaining items.” The component reports completion but does not invent product validation copy or switch intent automatically.

Catnip Design System by Signicat