Rate
Accessible star rating input with hover preview, keyboard control and optional half values.
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
value | number | 0 | Current rating and submitted form value. |
max | number | 5 | Number of rating icons. |
allow-half | boolean | false | Allow values in half-star steps. |
clearable | boolean | false | Clicking the committed rating again clears it to zero. |
readonly | boolean | false | Prevents changes while keeping the rating visually available. |
disabled | boolean | false | Disables interaction and form submission. |
required | boolean | false | Requires a rating greater than zero for native form validation. |
name | string | — | Name used when the rating participates in a form. |
aria-label | string | null | null | Accessible name of the rating control. |
Events
| Name | Type | Description |
|---|---|---|
rate-change | CustomEvent<RateChangeEventDetail> | Fired after the user commits a rating. detail.value is the new value. |
input | Event | Fired with rate-change for form and framework bindings. |
change | Event | Fired with rate-change after the value is committed. |
CSS custom properties
Grouped by semantic target and state from --c2-component__target__state--property. Click a group to collapse it; click a name to copy it.
| Name | Type | Default | Description |
|---|---|---|---|
--c2-rate__icon--size | pixel | 24px | |
--c2-rate__icon--color | color | #e4e4e7 | |
--c2-rate__icon--transition-duration | duration | 150ms | |
--c2-rate__icon__filled--color | color | #facc15 | |
--c2-rate__icon__preview--color | color | #fbbf24 | |
--c2-rate__icon__hover--scale | number | 1.12 | |
--c2-rate__container--gap | pixel | 4px | |
--c2-rate__container--border-radius | border-radius | 4px | |
--c2-rate__container__focus--outline | outline | 2px solid rgba(2, 101, 220, 0.4) | |
--c2-rate__container__focus--outline-offset | pixel | 3px | |
--c2-rate__container__disabled--opacity | opacity | 0.38 | |