Skip to content

Rating for Angular

AngularInputs

Picks a score on a short scale of stars or a custom symbol, with optional half steps, clearing, three sizes, and a non-interactive display mode that reads as text such as ‘3.5 of 5’. Follows the WAI-ARIA APG slider pattern: one tab stop, arrows, Page, Home, End, and digit keys. A Form control with a hidden input for native submission.

  • Half stepsWhole or half symbols, by pointer half or arrow keys, filled in the reading direction.
  • One tab stopThe APG slider pattern: arrows, Page, Home, End, and digit keys, announced as "3.5 of 5".
  • Display modeA non-interactive image with the same text for tables and cards.
  • Your symbolStars by default, or any icon; captions such as "Meets expectations" per step.
  • Form readyRequired, custom validation, clearable, and a hidden input for native forms.

Behavior, design tokens, and limitations are described on the Rating page; this page covers the Angular API.

import { Component } from '@angular/core';
import type { RatingValue } from '@absoluteui/components/rating';
import { AuiRating } from '@absoluteui/angular/rating';
@Component({
selector: 'app-review-score',
imports: [AuiRating],
template: `<aui-rating label="Overall performance" [allowHalf]="true" [(value)]="score"></aui-rating>`,
})
export class ReviewScoreComponent {
score: RatingValue = 3.5;
}
Terminal window
npm install @absoluteui/angular @absoluteui/components @absoluteui/core @absoluteui/theme

Setup with provideAbsoluteUI() is covered in Getting started. Styles are included with the component.

import { AuiRating } from '@absoluteui/angular/rating';

Defaults for every instance: provideAbsoluteUIConfig({ components: { rating: { ... } } }) (see Configuration).

Class AuiRating; template reference #ref="auiRating".

Server rendering: Renders on the server; the browser re-creates it after hydration.

Angular forms: implements ControlValueAccessor and Validator; the form value is RatingValue. Bind [formControl], formControlName, or [(ngModel)]; validation messages of the component report through the aui error key. See Forms.

Input Type Default Description
label string Required. Visible label (required accessible name).
hideLabel boolean false Visually hide the label.
description string Help text, referenced by the control.
max number '5' Number of symbols, 1 to 10.
allowHalf boolean false Allow half steps.
clearable boolean true Choosing the current value again, Delete, Backspace, or 0 clears the rating.
required boolean false A rating must be given.
disabled boolean false Disable the control.
readOnly boolean false Focusable and announced, but not changeable.
display boolean false Non-interactive display (role=img with the value text).
valueText (value: number, max: number) => string Full value text; default ‘{value} of {max}’.
labels readonly string[] Visible caption per whole step, such as ‘Good’.
name string Form field name (hidden input; empty when no rating).
validate (value: RatingValue) => string | null Consumer validation; return a message to mark the value invalid.
icons Partial<RatingIcons> Scale symbol (item) and validation icon (error).
size RatingSize 'md' Symbol size: ‘sm’, ‘md’, or ‘lg’.
validationTiming ValidationTiming 'blur' When validation messages appear.
locale string 'en-US' Locale of the value text and messages.
Model Type Change output Description
[(value)] RatingValue (valueChange) The value: [(value)] without forms; with Angular forms, bind the form control instead.
Output Payload Description
(changed) RatingValueDetail The user changed the score: { value, validity }. Re-emits aui-change.
(hovered) RatingHoverDetail The pointer previews a value (null when it leaves): { value }. Re-emits aui-hover.

Call them through a viewChild query or a template reference.

Method Description
setCustomError(message: string | null): void Show or clear an external error.
reportValidity(): boolean | undefined Show messages now and return validity.
focus(): void Focus the control.
reset(): void Restore the initial value and clear the validation state.

Pattern: WAI-ARIA APG Slider: one focusable role=slider with aria-valuenow, aria-valuemin (0 when clearable), aria-valuemax, and aria-valuetext such as ‘3.5 of 5’. Chosen over the radio group pattern because half steps and clearing are one value on a range and the control is a single tab stop. Display mode is role=img named by the label and the value text.

The Angular component renders the framework-neutral component, so its keyboard support, roles, WCAG 2.2 criteria, budgets, and import cost apply unchanged: see Rating: Accessibility and performance.