View as Markdown

API reference: @salmonui/inputs/rating

RatingPropsinterface

import type { RatingProps } from '@salmonui/inputs/rating';
interface RatingProps extends FieldCommonProps {
    readonly value?: number | undefined;
    readonly defaultValue?: number | undefined;
    readonly onValueChange?: ((value: number, details: RatingChangeDetails) => void) | undefined;
    readonly count?: number | undefined;
    readonly min?: number | undefined;
    readonly precision?: 'full' | 'half' | 'quarter' | 'exact' | undefined;
    readonly clearable?: boolean | undefined;
    readonly highlightSelectedOnly?: boolean | undefined;
    readonly showLabel?: boolean | undefined;
    readonly labelPlacement?: 'top' | 'bottom' | 'start' | 'end' | undefined;
    readonly renderLabel?: ((ctx: {
        readonly value: number;
        readonly count: number;
    }) => ReactNode) | undefined;
    readonly icon?: ReactNode;
    readonly emptyIcon?: ReactNode;
    readonly renderItem?: ((ctx: {
        readonly index: number;
        readonly state: RatingItemState;
        readonly fill: number;
    }) => ReactNode) | undefined;
    readonly showTooltip?: boolean | undefined;
    readonly renderTooltip?: ((ctx: {
        readonly value: number;
        readonly count: number;
    }) => ReactNode) | undefined;
    readonly onHoverChange?: ((value: number | null) => void) | undefined;
    readonly name?: string | undefined;
    readonly form?: string | undefined;
    readonly required?: boolean | undefined;
    readonly disabled?: boolean | undefined;
    readonly readOnly?: boolean | undefined;
    readonly localeText?: RatingLocaleText | undefined;
    readonly id?: string | undefined;
    readonly dir?: 'ltr' | 'rtl' | 'auto' | undefined;
    readonly className?: string | undefined;
    readonly style?: CSSProperties | undefined;
    readonly classNames?: {
        readonly label?: string;
        readonly items?: string;
        readonly item?: string;
        readonly value?: string;
        readonly description?: string;
        readonly error?: string;
    } | undefined;
    readonly ref?: Ref<HTMLElement> | undefined;
}
RatingProps members (36, 7 inherited)
NameSignatureDescription
labeloptionalinheritedlabel?: ReactNode;
descriptionoptionalinheriteddescription?: ReactNode;
errorMessageoptionalinheritederrorMessage?: ((ctx: { readonly errors: readonly string[]; }) => ReactNode) | ReactNode;

Error text (or a function of the errors) shown while the field is invalid.

invalidoptionalinheritedinvalid?: boolean;

Forces the error state.

validationoptionalinheritedvalidation?: FieldValidation;

Rules in the Data Grid vocabulary.

validateOnoptionalinheritedvalidateOn?: ValidateOn;

When errors appear; default the Form's, else 'blur'.

sizeoptionalinheritedsize?: FieldSize;

Metric set. Default 'md'.

valueoptionalreadonly value?: number | undefined;
defaultValueoptionalreadonly defaultValue?: number | undefined;

Default min.

onValueChangeoptionalreadonly onValueChange?: ((value: number, details: RatingChangeDetails) => void) | undefined;
countoptionalreadonly count?: number | undefined;

Number of items. Default 5.

minoptionalreadonly min?: number | undefined;

Lowest value a selection can set; the cleared value. Default 0.

precisionoptionalreadonly precision?: 'full' | 'half' | 'quarter' | 'exact' | undefined;

Step: 'full' or 'half' while editing; 'quarter' and 'exact' only with readOnly (a role="img" display). Default 'full'.

clearableoptionalreadonly clearable?: boolean | undefined;

Shows a clear button while the value is above min.

highlightSelectedOnlyoptionalreadonly highlightSelectedOnly?: boolean | undefined;

Fills only the selected item.

showLabeloptionalreadonly showLabel?: boolean | undefined;

Shows the value next to the items.

labelPlacementoptionalreadonly labelPlacement?: 'top' | 'bottom' | 'start' | 'end' | undefined;

Where the value label sits. Default 'end'.

renderLabeloptionalreadonly renderLabel?: ((ctx: { readonly value: number; readonly count: number; }) => ReactNode) | undefined;
iconoptionalreadonly icon?: ReactNode;

Filled icon. Default a star.

emptyIconoptionalreadonly emptyIcon?: ReactNode;

Empty icon. Default icon (drawn in the empty color).

renderItemoptionalreadonly renderItem?: ((ctx: { readonly index: number; readonly state: RatingItemState; readonly fill: number; }) => ReactNode) | undefined;

Replaces both icons of an item.

showTooltipoptionalreadonly showTooltip?: boolean | undefined;

Shows a value bubble over the hovered or focused step.

renderTooltipoptionalreadonly renderTooltip?: ((ctx: { readonly value: number; readonly count: number; }) => ReactNode) | undefined;
onHoverChangeoptionalreadonly onHoverChange?: ((value: number | null) => void) | undefined;

The step under the pointer, null when it leaves. Bound listeners only when given; no state.

nameoptionalreadonly name?: string | undefined;

Submitted name. Without it the radios share a generated name and are not submitted.

formoptionalreadonly form?: string | undefined;
requiredoptionalreadonly required?: boolean | undefined;
disabledoptionalreadonly disabled?: boolean | undefined;
readOnlyoptionalreadonly readOnly?: boolean | undefined;

Display only: radios stay focusable but ignore changes; 'quarter' / 'exact' render a role="img".

localeTextoptionalreadonly localeText?: RatingLocaleText | undefined;
idoptionalreadonly id?: string | undefined;
diroptionalreadonly dir?: 'ltr' | 'rtl' | 'auto' | undefined;
classNameoptionalreadonly className?: string | undefined;
styleoptionalreadonly style?: CSSProperties | undefined;
classNamesoptionalreadonly classNames?: { readonly label?: string; readonly items?: string; readonly item?: string; readonly value?: string; readonly description?: string; readonly error?: string; } | undefined;

Part classes: root is className; label, items, item, value, description, error.

refoptionalreadonly ref?: Ref<HTMLElement> | undefined;

The root element (<fieldset>, or <div> for the image display).