API reference: @salmonui/inputs/rating
Ratingcomponent
import { Rating } from '@salmonui/inputs/rating';function Rating(props: RatingProps): ReactNode;
Rating: one native radio per step (two per item with
precision="half") named by localeText.item, inside a
<fieldset role="radiogroup"> named by label. Arrow keys are the
browser's radio keys (mirrored in RTL); hover preview is CSS. Read-only
'quarter' / 'exact' precision renders one role="img" with a clipped
fill. ref is the root element.
Props: RatingProps
| Name | Signature | Description |
|---|---|---|
labeloptionalinherited | label?: ReactNode; | |
descriptionoptionalinherited | description?: ReactNode; | |
errorMessageoptionalinherited | errorMessage?: ((ctx: { readonly errors: readonly string[]; }) => ReactNode) | ReactNode; | Error text (or a function of the errors) shown while the field is invalid. |
invalidoptionalinherited | invalid?: boolean; | Forces the error state. |
validationoptionalinherited | validation?: FieldValidation; | Rules in the Data Grid vocabulary. |
validateOnoptionalinherited | validateOn?: ValidateOn; | When errors appear; default the |
sizeoptionalinherited | size?: FieldSize; | Metric set. Default |
valueoptional | readonly value?: number | undefined; | |
defaultValueoptional | readonly defaultValue?: number | undefined; | Default |
onValueChangeoptional | readonly onValueChange?: ((value: number, details: RatingChangeDetails) => void) | undefined; | |
countoptional | readonly count?: number | undefined; | Number of items. Default 5. |
minoptional | readonly min?: number | undefined; | Lowest value a selection can set; the cleared value. Default 0. |
precisionoptional | readonly precision?: 'full' | 'half' | 'quarter' | 'exact' | undefined; | Step: |
clearableoptional | readonly clearable?: boolean | undefined; | Shows a clear button while the value is above |
highlightSelectedOnlyoptional | readonly highlightSelectedOnly?: boolean | undefined; | Fills only the selected item. |
showLabeloptional | readonly showLabel?: boolean | undefined; | Shows the value next to the items. |
labelPlacementoptional | readonly labelPlacement?: 'top' | 'bottom' | 'start' | 'end' | undefined; | Where the value label sits. Default |
renderLabeloptional | readonly renderLabel?: ((ctx: {
readonly value: number;
readonly count: number;
}) => ReactNode) | undefined; | |
iconoptional | readonly icon?: ReactNode; | Filled icon. Default a star. |
emptyIconoptional | readonly emptyIcon?: ReactNode; | Empty icon. Default |
renderItemoptional | readonly renderItem?: ((ctx: {
readonly index: number;
readonly state: RatingItemState;
readonly fill: number;
}) => ReactNode) | undefined; | Replaces both icons of an item. |
showTooltipoptional | readonly showTooltip?: boolean | undefined; | Shows a value bubble over the hovered or focused step. |
renderTooltipoptional | readonly renderTooltip?: ((ctx: {
readonly value: number;
readonly count: number;
}) => ReactNode) | undefined; | |
onHoverChangeoptional | readonly onHoverChange?: ((value: number | null) => void) | undefined; | The step under the pointer, |
nameoptional | readonly name?: string | undefined; | Submitted name. Without it the radios share a generated name and are not submitted. |
formoptional | readonly form?: string | undefined; | |
requiredoptional | readonly required?: boolean | undefined; | |
disabledoptional | readonly disabled?: boolean | undefined; | |
readOnlyoptional | readonly readOnly?: boolean | undefined; | Display only: radios stay focusable but ignore changes; |
localeTextoptional | readonly localeText?: RatingLocaleText | undefined; | |
idoptional | readonly id?: string | undefined; | |
diroptional | readonly dir?: 'ltr' | 'rtl' | 'auto' | undefined; | |
classNameoptional | readonly className?: string | undefined; | |
styleoptional | readonly style?: CSSProperties | undefined; | |
classNamesoptional | readonly classNames?: {
readonly label?: string;
readonly items?: string;
readonly item?: string;
readonly value?: string;
readonly description?: string;
readonly error?: string;
} | undefined; | Part classes: |
refoptional | readonly ref?: Ref<HTMLElement> | undefined; | The root element ( |