Rating
vig-rating
import { Rating } from '@vigdx/ui/rating';Basic
[(value)] to a number | null signal; null means not rated. Hovering previews a value without changing it.
Value: 3
Half steps, clearing, icons and sizes
allowHalf picks half icons (the half under the pointer, from the inline start) and steps the arrows by 0.5. clearable clears the rating when the current value is picked again or Delete is pressed. max sets the number of icons, icon any registered glyph, size the scale ( sm , md , lg ).
Pick the current rating again, or press Delete, to clear it.
Read-only, disabled and error
readonly shows a fixed rating, which may be fractional (an average fills part of an icon); it stays focusable and is announced, e.g. "3.7 of 5". Disabled ratings leave the tab order. Errors show once the field is touched and invalid.
From 128 reviews
Signal Forms
vig-rating implements FormValueControl<number | null> . A schema max() sets the number of icons; other rules show their message once the rating is touched.
Valid: no · none
Reactive Forms
VigValueAccessor next to the component to use formControlName , [formControl] or ngModel .
4 · pristine
Styling hooks
Internal elements carry a stable data-part and the component's data-scope; both are public API, so removing one is a breaking change. Select a part by both, e.g. [data-scope="rating"][data-part="label"] { … }: the pair stays within this component when kit components nest, and also reaches parts in overlay panels, which render outside the host. State is exposed through aria-* and, where listed, a data-state; literal values are checked by the API gate, values computed from the component's state follow its documented types. Other data-* attributes listed below (such as data-opening while an overlay animates) are API too. See Customizing.
Scope: [data-scope="rating"]
| Part | Element | data-state |
|---|---|---|
label | aria-labelledby of the control). | — |
control | role="slider" row of icons; preview while a pointer hovers. | preview |
item | full, partial, empty | |
fill | — | |
hint | vig-hint (a display: contents host; style its text part). | — |
disabled-reason | vig-hint with the disabled reason ( display: contents ). | — |
error | vig-field-error (a display: contents host; style its message part). | — |
Accessibility
- One
role="slider", as in the APG rating slider example, not a radio group: a single tab stop, half steps and clearing map onto one number (a radio group would need two radios per icon plus a "none" radio), and screen readers announce the value as "3 of 5" througharia-valuetext(labels.valueLabel), or "No rating" (labels.emptyLabel). - Right and Up raise the rating, Left and Down lower it (Left and Right swap under RTL), Page Up and Page Down move by a whole icon, Home and End jump to the lowest and highest rating. With
clearablethe slider's minimum is 0 ("No rating"): Home, stepping below the lowest rating, Delete and Backspace clear it; without it the minimum is the lowest rating. - Filled icons are solid, empty ones outlined in
--color-border-control: the state reads from the shape, also in forced-colors mode, and both hold 3:1 against the page. The filled color is the--color-ratingtoken. - Each icon cell is at least 24px (44px on touch screens). The hover preview is for mouse and pen only.
readonlykeeps the rating focusable witharia-readonly. The slider role has noaria-required, sorequiredadds a visually hidden "Required" to the description.
API
Rating
vig-ratingA star rating: pick a whole (or, with allowHalf, half) number of icons
out of max. clearable lets the user take the rating back by picking
the current value again (or with Delete). readonly shows a fixed rating
that is still announced ("3.5 of 5") and may be fractional, e.g. an
average.
<vig-rating label="Your rating" [(value)]="stars" clearable />It is one role="slider" (the APG rating slider): a single tab stop whose
arrows step by one icon (or half), mirrored under RTL, Home and End jump to
the ends; with clearable, Home and stepping below the lowest rating clear
it. Pointers preview the value on hover. Works with Signal Forms and,
through VigValueAccessor, with Reactive Forms and ngModel.
| Name | Type | Default | Description |
|---|---|---|---|
allowHalf | boolean | false | Lets the user pick half icons; arrows then step by 0.5. |
clearable | boolean | false | Picking the current value again (or pressing Delete) clears the rating. |
dirty | boolean | false | — |
disabled | boolean | false | — |
disabledReasons | readonly WithOptionalFieldTree<DisabledReason>[] | [] | — |
errorMessages | Record<string, string> | — | — |
errors | readonly ValidationError.WithOptionalFieldTree[] | [] | — |
hidden | boolean | false | — |
hideLabel | boolean | false | Keeps the label for assistive tech only. |
hint | string | undefined | undefined | — |
icon | string | 'star' | Name of a registered |
invalid | boolean | false | — |
label | string | — | — |
labels | Partial<RatingLabels> | — | Texts (i18n); locale defaults. |
max | number | undefined | 5 | The number of icons, the highest rating (default 5). |
name | string | '' | — |
pending | boolean | false | — |
readonly | boolean | false | — |
required | boolean | false | — |
size | FieldSize | 'md' | — |
touched | boolean | false | — |
value | number | null | null | The rating, |
| Name | Payload | Description |
|---|---|---|
touch | void | — |
valueChange | number | null | The rating, |
| Signature | Description |
|---|---|
focus(options?: FocusOptions): void | Moves focus to the control's interactive element (the input, or the
trigger of a popup control). Signal Forms calls it through
|
reset(): void | Returns the control to its pristine look: drops in-progress text, closes
an open popup, clears errors the component raised itself and the
submitted state of |