Field

A controlled form field component.

Props#

InputField#

PropTypeDefaultDescription
errorBorderColorstringThe border color when the input is invalid. Use color keys in `theme.colors`
focusBorderColorstringThe border color when the input is focused. Use color keys in `theme.colors`
htmlSizenumberThe native HTML size attribute to be passed to the input
isDisabledbooleanfalseIf true, the form control will be disabled. This has 2 side effects: - The FormLabel will have `data-disabled` attribute - The form element (e.g, Input) will be disabled
isInvalidbooleanfalseIf true, the form control will be invalid. This has 2 side effects: - The FormLabel and FormErrorIcon will have `data-invalid` set to true - The form element (e.g, Input) will have `aria-invalid` set to true
isReadOnlybooleanfalseIf true, the form control will be readonly
isRequiredbooleanfalseIf true, the form control will be required. This has 2 side effects: - The FormLabel will show a required indicator - The form element (e.g, Input) will have `aria-required` set to true
leftAddontype ONLY_FOR_FORMAT = | string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | PromiseLikeOfReactNode
rightAddontype ONLY_FOR_FORMAT = | string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | PromiseLikeOfReactNode
typestring

NumberInputField#

PropTypeDefaultDescription
typerequired"number"
allowMouseWheelbooleanIf true, the input's value will change based on mouse wheel
aria-describedbystring
aria-labelstring
aria-labelledbystring
clampValueOnBlurbooleantrueThis controls the value update when you blur out of the input. - If true and the value is greater than max, the value will be reset to max - Else, the value remains the same.
decrementIcontype ONLY_FOR_FORMAT = | string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | PromiseLikeOfReactNodeRender a custom decrement icon.
defaultValuestring | numberThe initial value of the counter. Should be less than max and greater than min
errorBorderColorstringThe border color when the input is invalid. Use color keys in `theme.colors`
fieldPropsNumberInputFieldPropsProps to pass to the NumberInputField component.
focusBorderColorstringThe border color when the input is focused. Use color keys in `theme.colors`
focusInputOnChangebooleantrueIf true, the input will be focused as you increment or decrement the value with the stepper
format(value: string | number) => string | numberIf using a custom display format, this converts the default format to the custom format.
getAriaValueText(value: string | number) => stringThis is used to format the value so that screen readers can speak out a more human-friendly value. It is used to set the `aria-valuetext` property of the input
hideStepperbooleanHide the stepper.
idstringThe id to use for the number input field.
incrementIcontype ONLY_FOR_FORMAT = | string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | PromiseLikeOfReactNodeRender a custom increment icon.
inputModetype ONLY_FOR_FORMAT = | "search" | "text" | "email" | "tel" | "none" | "url" | "numeric" | "decimal"decimalHints at the type of data that might be entered by the user. It also determines the type of keyboard shown to the user on mobile devices
isDisabledbooleanWhether the input should be disabled
isInvalidbooleanIf true, the input will have `aria-invalid` set to true
isReadOnlybooleanIf true, the input will be in readonly mode
isRequiredbooleanWhether the input is required
isValidCharacter(value: string) => booleanWhether the pressed key should be allowed in the input. The default behavior is to allow DOM floating point characters defined by /^[Ee0-9+\-.]$/
keepWithinRangebooleantrueThis controls the value update behavior in general. - If true and you use the stepper or up/down arrow keys, the value will not exceed the max or go lower than min - If false, the value will be allowed to go out of range.
maxnumberNumber.MAX_SAFE_INTEGERThe maximum value of the counter
minnumberNumber.MIN_SAFE_INTEGERThe minimum value of the counter
namestringThe HTML name attribute used for forms
onBlurFocusEventHandler<HTMLInputElement>
onChange(valueAsString: string, valueAsNumber: number) => voidThe callback fired when the value changes
onFocusFocusEventHandler<HTMLInputElement>
onInvalid( message: ValidityState, value: string, valueAsNumber: number, ) => void
parse(value: string) => stringIf using a custom display format, this converts the custom format to a format parseFloat understands.
patternstring[0-9]*(.[0-9]+)?The pattern used to check the <input> element's value against on form submission.
placeholderstringThe placeholder text when no value is selected.
precisionnumberThe number of decimal points used to round the value
stepnumber1The step used to increment or decrement the value
valuestring | numberThe value of the counter. Should be less than max and greater than min

PasswordInputField#

TextareaField#

PropTypeDefaultDescription
errorBorderColorstringThe border color when the textarea is invalid. Use color keys in `theme.colors`
focusBorderColorstringThe border color when the textarea is focused. Use color keys in `theme.colors`
isDisabledbooleanfalseIf true, the form control will be disabled. This has 2 side effects: - The FormLabel will have `data-disabled` attribute - The form element (e.g, Input) will be disabled
isInvalidbooleanfalseIf true, the form control will be invalid. This has 2 side effects: - The FormLabel and FormErrorIcon will have `data-invalid` set to true - The form element (e.g, Input) will have `aria-invalid` set to true
isReadOnlybooleanfalseIf true, the form control will be readonly
isRequiredbooleanfalseIf true, the form control will be required. This has 2 side effects: - The FormLabel will show a required indicator - The form element (e.g, Input) will have `aria-required` set to true

SwitchField#

PropTypeDefaultDescription
aria-describedbystring
aria-invalidtrue
aria-labelstringDefines the string that labels the checkbox element.
aria-labelledbystringRefers to the id of the element that labels the checkbox element.
defaultCheckedbooleanfalseIf true, the checkbox will be initially checked.
idstringid assigned to input
isCheckedbooleanfalseIf true, the checkbox will be checked. You'll need to pass onChange to update its value (since it is now controlled)
isDisabledbooleanfalseIf true, the checkbox will be disabled
isFocusablebooleanfalseIf true and isDisabled is passed, the checkbox will remain tabbable but not interactive
isInvalidbooleanfalseIf true, the checkbox is marked as invalid. Changes style of unchecked state.
isReadOnlybooleanfalseIf true, the checkbox will be readonly
isRequiredbooleanfalseIf true, the checkbox input is marked as required, and required attribute will be added
namestringThe name of the input field in a checkbox (Useful for form submission).
onBlur(event: FocusEvent<HTMLInputElement, Element>) => voidThe callback invoked when the checkbox is blurred (loses focus)
onChange(event: ChangeEvent<HTMLInputElement>) => voidThe callback invoked when the checked state of the Checkbox changes.
onFocus(event: FocusEvent<HTMLInputElement, Element>) => voidThe callback invoked when the checkbox is focused
spacingResponsiveValue<number | "px" | (string & {}) | "-moz-initial" | "inherit" | "initial" | "revert" | "revert-layer" | "unset" | "auto" | "1" | "-1" | "2" | "-2" | "3" | "-3" | "4" | "-4" | "5" | "-5" | ... 54 more ... | "-3.5">0.5remThe spacing between the switch and its label text
tabIndexnumberThe tab-index property of the underlying input element.
valuestring | numberThe value to be used in the checkbox input. This is the value that will be returned on form submission.

SelectField#

PropTypeDefaultDescription
namerequiredstringThe name of the input field in a native form.
arrowPaddingnumber8The padding required to prevent the arrow from reaching the very edge of the popper.
autoSelectbooleantrueIf true, the first enabled menu item will receive focus and be selected when the menu opens.
boundaryHTMLElement | "clippingParents" | "scrollParent"clippingParentsThe boundary area for the popper. Used within the preventOverflow modifier
buttonPropsSelectButtonProps
closeOnBlurbooleantrueIf true, the menu will close when you click outside the menu list
closeOnSelectbooleantrueIf true, the menu will close when a menu item is clicked
computePositionOnMountboolean
defaultIsOpenboolean
defaultValuestring | string[]The initial value of the select field.
direction"ltr" | "rtl"If rtl, proper placement positions will be flipped i.e. 'top-right' will become 'top-left' and vice-verse
eventListenerstype ONLY_FOR_FORMAT = | boolean | { scroll?: boolean | undefined resize?: boolean | undefined }trueIf provided, determines whether the popper will reposition itself on scroll and resize of the window.
flipbooleantrueIf true, the popper will change its placement and flip when it's about to overflow its boundary area.
gutternumber8The distance or margin between the reference and popper. It is used internally to create an offset modifier. NB: If you define offset prop, it'll override the gutter.
idstring
initialFocusRefRefObject<{ focus(): void }>The ref of the element that should receive focus when the popover opens.
isDisabledbooleanIf true, the select will be disabled.
isLazybooleanfalsePerformance 🚀: If true, the MenuItem rendering will be deferred until the menu is open.
isOpenboolean
lazyBehaviorLazyModeunmountPerformance 🚀: The lazy behavior of menu's content when not visible. Only works when `isLazy={true}` - "unmount": The menu's content is always unmounted when not open. - "keepMounted": The menu's content initially unmounted, but stays mounted when menu is open.
listPropsSelectListProps
matchWidthbooleanfalseIf true, the popper will match the width of the reference at all times. It's useful for autocomplete, `date-picker` and select patterns.
modifiersPartial<Modifier<string, any>>[]Array of popper.js modifiers. Check the docs to see the list of possible modifiers you can pass.
multiplebooleanEnable multiple select.
offset[number, number]The main and cross-axis offset to displace popper element from its reference element.
onChange(value: string | string[]) => voidThe callback invoked when the value of the select field changes.
onClose() => void
onOpen() => void
optionsFieldOptions<SelectOption>An array of options If you leave this empty the children prop will be rendered.
placeholderstringThe placeholder text when there's no value.
placementPlacementWithLogicalbottomThe placement of the popper relative to its reference.
preventOverflowbooleantrueIf true, will prevent the popper from being cut off and ensure it's visible within the boundary area.
renderValue(value: string | string[]) => ReactNodeThe function used to render the value of the select field.
strategy"fixed" | "absolute"absoluteThe CSS positioning strategy to use.
valuestring | string[]The value of the select field.

CheckboxField#

PropTypeDefaultDescription
aria-describedbystring
aria-invalidtrue
aria-labelstringDefines the string that labels the checkbox element.
aria-labelledbystringRefers to the id of the element that labels the checkbox element.
iconReactElement<any, string | JSXElementConstructor<any>>CheckboxIconThe checked icon to use
iconColorstringThe color of the checkbox icon when checked or indeterminate
iconSizestring | numberThe size of the checkbox icon when checked or indeterminate
idstringid assigned to input
inputPropsInputHTMLAttributes<HTMLInputElement>Additional props to be forwarded to the input element
isCheckedbooleanfalseIf true, the checkbox will be checked. You'll need to pass onChange to update its value (since it is now controlled)
isDisabledbooleanfalseIf true, the checkbox will be disabled
isFocusablebooleanfalseIf true and isDisabled is passed, the checkbox will remain tabbable but not interactive
isIndeterminatebooleanfalseIf true, the checkbox will be indeterminate. This only affects the icon shown inside checkbox and does not modify the isChecked property.
isInvalidbooleanfalseIf true, the checkbox is marked as invalid. Changes style of unchecked state.
isReadOnlybooleanfalseIf true, the checkbox will be readonly
isRequiredbooleanfalseIf true, the checkbox input is marked as required, and required attribute will be added
namestringThe name of the input field in a checkbox (Useful for form submission).
onChange(event: ChangeEvent<HTMLInputElement>) => voidThe callback invoked when the checked state of the Checkbox changes.
onFocus(event: FocusEvent<HTMLInputElement, Element>) => voidThe callback invoked when the checkbox is focused
spacingResponsiveValue<number | "px" | (string & {}) | "-moz-initial" | "inherit" | "initial" | "revert" | "revert-layer" | "unset" | "auto" | "1" | "-1" | "2" | "-2" | "3" | "-3" | "4" | "-4" | "5" | "-5" | ... 54 more ... | "-3.5">0.5remThe spacing between the checkbox and its label text
tabIndexnumberThe tab-index property of the underlying input element.
valuestring | numberThe value to be used in the checkbox input. This is the value that will be returned on form submission.

RadioField#

PropTypeDefaultDescription
optionsrequiredRadioOptions
defaultValuestringThe value of the radio to be checked initially (in uncontrolled mode)
directionStackDirection
isDisabledbooleanfalseIf true, all wrapped radio inputs will be disabled
isFocusablebooleanfalseIf true and isDisabled is true, all wrapped radio inputs will remain focusable but not interactive.
isNativebooleanfalseIf true, input elements will receive checked attribute instead of isChecked. This assumes, you're using native radio inputs
namestringThe name attribute forwarded to each radio element
onChange(nextValue: string) => voidFunction called once a radio is checked
spacingResponsiveValue<number | "px" | (string & {}) | "-moz-initial" | "inherit" | "initial" | "revert" | "revert-layer" | "unset" | "auto" | "1" | "-1" | "2" | "-2" | "3" | "-3" | "4" | "-4" | "5" | "-5" | ... 54 more ... | "-3.5">
valuestringThe value of the radio to be checked (in controlled mode)

PinField#

PropTypeDefaultDescription
autoFocusbooleanIf true, the pin input receives focus on mount
defaultValuestringThe default value of the pin input
idstringThe top-level id string that will be applied to the input fields. The index of the input will be appended to this top-level id.
isDisabledbooleanIf true, the pin input component is put in the disabled state
isInvalidbooleanIf true, the pin input component is put in the invalid state
manageFocusbooleantrueIf true, focus will move automatically to the next input once filled
maskbooleanIf true, the input's value will be masked just like `type=password`
onChange(value: string) => voidFunction called on input change
onComplete(value: string) => voidFunction called when all inputs have valid values
otpbooleanIf true, the pin input component signals to its fields that they should use `autocomplete="one-time-code"`.
pinLengthnumber
pinType"number" | "alphanumeric"
placeholderstringThe placeholder for the pin input
spacingResponsiveValue<number | "px" | (string & {}) | "-moz-initial" | "inherit" | "initial" | "revert" | "revert-layer" | "unset" | "auto" | "1" | "-1" | "2" | "-2" | "3" | "-3" | "4" | "-4" | "5" | "-5" | ... 54 more ... | "-3.5">
valuestringThe value of the pin input. This is the value that will be returned when the pin input is filled

NativeSelectField#

PropTypeDefaultDescription
errorBorderColorstringThe border color when the select is invalid. Use color keys in `theme.colors`
focusBorderColorstringThe border color when the select is focused. Use color keys in `theme.colors`
iconReactElement<any, string | JSXElementConstructor<any>>The icon element to use in the select
iconColorstringThe color of the icon
iconSizestringThe size (width and height) of the icon
isDisabledbooleanfalse
isInvalidbooleanfalseIf true, the form control will be invalid. This has 2 side effects: - The FormLabel and FormErrorIcon will have `data-invalid` set to true - The form element (e.g, Input) will have `aria-invalid` set to true
isReadOnlybooleanfalseIf true, the form control will be readonly
isRequiredbooleanfalseIf true, the form control will be required. This has 2 side effects: - The FormLabel will show a required indicator - The form element (e.g, Input) will have `aria-required` set to true
optionsOption[]
placeholderstringThe placeholder for the select. We render an `<option/>` element that has empty value. ```jsx <option value="">{placeholder}</option> ```
rootPropsRootPropsProps to forward to the root div element

Was this helpful?