@base-ui-components/react
Version:
Base UI is a library of headless ('unstyled') React components and low-level hooks. You gain complete control over your app's CSS and accessibility features.
130 lines • 3.87 kB
TypeScript
import * as React from 'react';
import type { BaseUIComponentProps } from "../../utils/types.js";
import type { FieldRoot } from "../../field/root/FieldRoot.js";
import { BaseUIEventDetails } from "../../utils/createBaseUIEventDetails.js";
/**
* Groups all parts of the number field and manages its state.
* Renders a `<div>` element.
*
* Documentation: [Base UI Number Field](https://base-ui.com/react/components/number-field)
*/
export declare const NumberFieldRoot: React.ForwardRefExoticComponent<NumberFieldRoot.Props & React.RefAttributes<HTMLDivElement>>;
export declare namespace NumberFieldRoot {
interface Props extends Omit<BaseUIComponentProps<'div', State>, 'onChange'> {
/**
* The id of the input element.
*/
id?: string;
/**
* The minimum value of the input element.
*/
min?: number;
/**
* The maximum value of the input element.
*/
max?: number;
/**
* The small step value of the input element when incrementing while the meta key is held. Snaps
* to multiples of this value.
* @default 0.1
*/
smallStep?: number;
/**
* Amount to increment and decrement with the buttons and arrow keys,
* or to scrub with pointer movement in the scrub area.
* @default 1
*/
step?: number;
/**
* The large step value of the input element when incrementing while the shift key is held. Snaps
* to multiples of this value.
* @default 10
*/
largeStep?: number;
/**
* Whether the user must enter a value before submitting a form.
* @default false
*/
required?: boolean;
/**
* Whether the component should ignore user interaction.
* @default false
*/
disabled?: boolean;
/**
* Whether the user should be unable to change the field value.
* @default false
*/
readOnly?: boolean;
/**
* Identifies the field when a form is submitted.
*/
name?: string;
/**
* The raw numeric value of the field.
*/
value?: number | null;
/**
* The uncontrolled value of the field when it’s initially rendered.
*
* To render a controlled number field, use the `value` prop instead.
*/
defaultValue?: number;
/**
* Whether to allow the user to scrub the input value with the mouse wheel while focused and
* hovering over the input.
* @default false
*/
allowWheelScrub?: boolean;
/**
* Whether the value should snap to the nearest step when incrementing or decrementing.
* @default false
*/
snapOnStep?: boolean;
/**
* Options to format the input value.
*/
format?: Intl.NumberFormatOptions;
/**
* Callback fired when the number value changes.
*/
onValueChange?: (value: number | null, eventDetails: ChangeEventDetails) => void;
/**
* The locale of the input element.
* Defaults to the user's runtime locale.
*/
locale?: Intl.LocalesArgument;
/**
* A ref to access the hidden input element.
*/
inputRef?: React.Ref<HTMLInputElement>;
}
interface State extends FieldRoot.State {
/**
* The raw numeric value of the field.
*/
value: number | null;
/**
* The formatted string value presented in the input element.
*/
inputValue: string;
/**
* Whether the user must enter a value before submitting a form.
*/
required: boolean;
/**
* Whether the component should ignore user interaction.
*/
disabled: boolean;
/**
* Whether the user should be unable to change the field value.
*/
readOnly: boolean;
/**
* Whether the user is currently scrubbing the field.
*/
scrubbing: boolean;
}
type ChangeEventReason = 'none';
type ChangeEventDetails = BaseUIEventDetails<ChangeEventReason>;
}