View as Markdown

API reference: @salmonui/inputs/number-field

NumberFieldPropsinterface

import type { NumberFieldProps } from '@salmonui/inputs/number-field';
interface NumberFieldProps extends FieldCommonProps, NativeInput {
    readonly value?: number | null | undefined;
    readonly defaultValue?: number | null | undefined;
    readonly onValueChange?: ((value: number | null, details: NumberChangeDetails) => void) | undefined;
    readonly min?: number | undefined;
    readonly max?: number | undefined;
    readonly step?: number | undefined;
    readonly showStepper?: boolean | undefined;
    readonly formatOptions?: Intl.NumberFormatOptions | undefined;
    readonly format?: string | undefined;
    readonly currency?: string | undefined;
    readonly locale?: string | undefined;
    readonly decimals?: number | undefined;
    readonly restrictDecimals?: boolean | undefined;
    readonly clampBehavior?: 'blur' | 'none' | undefined;
    readonly incrementOnWheel?: boolean | undefined;
    readonly clearable?: boolean | undefined;
    readonly startAdornment?: ReactNode;
    readonly endAdornment?: ReactNode;
    readonly localeText?: NumberFieldLocaleText | undefined;
    readonly className?: string | undefined;
    readonly style?: CSSProperties | undefined;
    readonly classNames?: {
        readonly group?: string;
        readonly input?: string;
        readonly label?: string;
        readonly description?: string;
        readonly error?: string;
        readonly stepper?: string;
    } | undefined;
    readonly ref?: Ref<HTMLInputElement> | undefined;
}
NumberFieldProps members (30, 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 | null | undefined;
defaultValueoptionalreadonly defaultValue?: number | null | undefined;
onValueChangeoptionalreadonly onValueChange?: ((value: number | null, details: NumberChangeDetails) => void) | undefined;
minoptionalreadonly min?: number | undefined;
maxoptionalreadonly max?: number | undefined;
stepoptionalreadonly step?: number | undefined;

Arrow keys and the stepper change the value by step; Page keys by ten steps. Default 1.

showStepperoptionalreadonly showStepper?: boolean | undefined;

Increment and decrement buttons. Default true.

formatOptionsoptionalreadonly formatOptions?: Intl.NumberFormatOptions | undefined;

Intl.NumberFormat options of the blurred text.

formatoptionalreadonly format?: string | undefined;

A Data Grid column.format preset or pattern instead ('n2', 'C2', 'P1', '#,##0.00').

currencyoptionalreadonly currency?: string | undefined;

ISO 4217 code for currency formats.

localeoptionalreadonly locale?: string | undefined;

BCP 47 locale for formatting and parsing. Default 'en-US'; the host locale is never read.

decimalsoptionalreadonly decimals?: number | undefined;

Fraction digits the committed value is rounded to.

restrictDecimalsoptionalreadonly restrictDecimals?: boolean | undefined;

Refuses typing more fraction digits than decimals.

clampBehavioroptionalreadonly clampBehavior?: 'blur' | 'none' | undefined;

'blur' (default) clamps to min / max on blur; 'none' keeps the value and reports the range error.

incrementOnWheeloptionalreadonly incrementOnWheel?: boolean | undefined;

Mouse wheel over the focused field steps the value. Default false.

clearableoptionalreadonly clearable?: boolean | undefined;
startAdornmentoptionalreadonly startAdornment?: ReactNode;
endAdornmentoptionalreadonly endAdornment?: ReactNode;
localeTextoptionalreadonly localeText?: NumberFieldLocaleText | undefined;
classNameoptionalreadonly className?: string | undefined;
styleoptionalreadonly style?: CSSProperties | undefined;
classNamesoptionalreadonly classNames?: { readonly group?: string; readonly input?: string; readonly label?: string; readonly description?: string; readonly error?: string; readonly stepper?: string; } | undefined;
refoptionalreadonly ref?: Ref<HTMLInputElement> | undefined;

The native <input>.