Skip to main content
cngx-src documentation

CngxRating

ComponentPrimaryOnPushv0.1.0WCAG AA

projects/forms/input/rating/rating.component.ts

Import#

import { CngxRating } from '@cngx/forms/input'

Description#

Star/heart rating value control for cngx-form-field.

Renders its own strip of role="radio" buttons inside a roving-tabindex container, so arrow keys move and auto-select across stars and the value is a positional number (value >= step drives cumulative fill). It composes the roving keyboard engine (CngxRovingTabindex + CngxRovingItem) rather than reinventing navigation, and provides CNGX_FORM_FIELD_CONTROL so it drops straight into <cngx-form-field>.

The per-star glyph is a consumer slot (*cngxRatingItem); the control ships a minimal internal default and no icon component. The chosen value is announced through a polite live region on every committed change.

<cngx-form-field [field]="f.score">
  <cngx-rating [(value)]="score" [max]="5" />
</cngx-form-field>

https://cngxjs.github.io/cngx/examples/#/forms/input/rating/basic

Metadata#

Host#

Providers#

CNGX_FORM_FIELD_CONTROL
useExisting CngxRating

Relationships

Index#

Inputs#

allowHalf#boolean
input()

When true, the strip offers half-star steps (0.5, 1, 1.5, ...).

default false
ariaLabel#string
input()

Accessible label used when the control is standalone (no cngx-form-field). Inside a field the external label wins via aria-labelledby.

default ''
disabledInput#boolean
input()

Consumer disable knob. The effective disabled also folds in the surrounding field's disabled state, so a disabled Signal-Forms field disables the strip without an explicit binding.

default false, { alias: 'disabled' }
disabledReason#string
input()

Reason announced via aria-describedby while the control is disabled.

default ''
input()

Highest selectable rating - the number of whole stars. Default 5.

default 5
value#number
model()

Current rating. Two-way bindable; 0 means unrated.

default 0

Outputs#

value#number
model()

Current rating. Two-way bindable; 0 means unrated.

Instance Properties#

focused#unknown
Readonly
this.focusedState.asReadonly()

Methods#

focus#void
focus(options?: FocusOptions)
@paramoptions?FocusOptions

HostBindings#

BindingExpression
[id]id()
[attr.aria-label]ariaLabelAttr()
[attr.aria-labelledby]labelledBy()
[attr.aria-required]ariaRequired()
[attr.aria-invalid]ariaInvalid()
[attr.aria-disabled]ariaDisabled()
[attr.aria-describedby]describedBy()
[class.cngx-rating--disabled]disabled()
[class.cngx-rating--focused]focused()

HostListeners#

EventHandler
(focusin)focusin()
(focusout)focusout()