Skip to content

Rating

Displays a star rating that allows users to view and set ratings.

First release: 1.0.0 Latest update: July 1, 2025 Current version: 1.0.0

React Angular Vue Svelte HTML

Import

import { PlusRating } from '@plusui/react';
import { PlusRatingComponent } from '@plusui/angular';
import { PlusRating } from '@plusui/vue';
import PlusRating from '@plusui/svelte';
<script src="https://cdn.jsdelivr.net/npm/@plusui/core"></script>

Package

@plusui/react
@plusui/angular
@plusui/vue
@plusui/svelte
@plusui/core

Docs

Changelog

Rating Changelog

Recent changes and updates for the rating component

v1.0.0

June 20, 2025
Feat

Added Rating component for star ratings

  • Customizable star count
  • Half-star precision support
  • Read-only and interactive modes
  • Custom icons support
  • Accessibility with ARIA attributes

The Rating component allows users to view or interactively select a rating, typically represented by stars. It supports different sizes, fractional steps, form validation, readonly/disabled states, label/description slots, and custom symbols.

Rating - anatomy

A simple rating component allowing users to select a value.

Show code

Use the size prop to control the rating item size.

Show code

The step prop allows fractional ratings. The older precision prop is still supported as an alias.

Show code

Use the max prop to set the maximum number of rating items.

Show code

Set readonly to display a rating without allowing changes, or disabled to make it visually disabled and non-interactive.

Show code

Use empty-icon-name and filled-icon-name to specify different icons.

Show code

Use the symbolFormatter property when each symbol needs custom trusted HTML.

Show code

Use label and description props to add context. Use the matching slots when the content needs markup. The older caption prop remains supported as an alias for description.

Show code

Set required and name to use the rating in a native form. The component supports form reset, native input/change events, and setCustomValidity().

SubmitReset
Show code

Listen to rating changes and hover events for interactive feedback.

Show code
Show console
Rating - layout spacing Rating - light & dark mode
  • Keyboard Behavior:
    • The rating component is focusable (Tab).
    • When focused, ArrowLeft/ArrowDown decreases the rating by step.
    • ArrowRight/ArrowUp increases the rating by step.
    • Home sets the rating to 0.
    • End sets the rating to max.
    • PageUp and PageDown move the value by 10% of the scale or at least one step.
  • Screen Reader:
    • The component uses role="slider".
    • aria-valuemin="0", aria-valuemax, and aria-valuenow reflect the rating state.
    • aria-label or aria-labelledby provides the accessible name (uses label prop if provided).
    • aria-describedby points to the caption if present.
    • aria-readonly and aria-disabled reflect the respective states.
    • aria-valuetext provides a human-readable version of the current value (e.g., “3 out of 5 stars”).
    • aria-required indicates if the rating is mandatory.
    • aria-invalid indicates an error state (e.g., if required but no value set).
  • Required Developer Actions:
    • Provide a label prop or ensure an external label is associated via aria-labelledby for context.
    • If used in a form and required, set the required prop.
NameTypeDefaultDescriptionRequired
valuenumber0The current rating value.No
maxnumber5The maximum rating value (number of items).No
stepnumber1The value step (e.g., 1 for full stars, 0.5 for half stars).No
precisionnumber1Backward-compatible alias for step.No
readonlybooleanfalseMakes the rating display-only, preventing user interaction.No
disabledbooleanfalseDisables the rating component entirely.No
size'sm' | 'md' | 'lg' | 'xl''md'Size of the rating items.No
namestringundefinedName attribute, potentially for form integration.No
emptyIconNamestring'star'The icon name to use for empty rating items.No
emptyIconStyle'solid' | 'regular' | 'light''regular'The icon style to use for empty rating items.No
filledIconNamestring'star'The icon name to use for filled rating items.No
filledIconStyle'solid' | 'regular' | 'light''solid'The icon style to use for filled rating items.No
symbolFormatter(value: number, selected: boolean) => stringundefinedReturns trusted custom HTML for each symbol layer.No
labelstringundefinedAn accessible label for the rating component.No
descriptionstringundefinedOptional descriptive text displayed below the rating.No
captionstringundefinedBackward-compatible alias for description.No
requiredbooleanfalseIndicates if a rating value is required.No
NamePayload TypeDescription
plus-inputCustomEvent<{ value: number }>Fired when pointer or keyboard input changes the value.
plus-changeCustomEvent<{ value: number }>Fired when the rating value changes via user interaction.
plus-hoverCustomEvent<{ phase: string, value: number }>Fired when pointer hover previews a value (phase: move/end).
plus-focusCustomEvent<void>Fired when the rating receives focus.
plus-blurCustomEvent<void>Fired when the rating loses focus.
NameDescription
labelLabel content.
descriptionDescription content.
NameDescription
labelThe rating label.
descriptionThe rating description or validation message.
ratingThe focusable rating control.
symbolIndividual rating symbol.
symbol-selectedSelected overlay for each symbol.
symbol-unselectedUnselected symbol layer.
NameDefault ValueDescription
--rating-active-colorvar(--plus-color-text-primary)Color of active/selected symbols.
--rating-inactive-colorvar(--plus-color-text-caption)Color of inactive/empty symbols.
--rating-focus-ringvar(--plus-color-border-ring)Focus ring color.

Join the Community

Plus UI is built by the community. Join us on our platforms to contribute, get help, and stay up to date.