Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface TextFieldHookOptions

remarks

@since 2.5.0

Hierarchy

Index

Properties

counter?: boolean

Boolean if the FormMessage should also display a counter for the remaining letters allowed based on the maxLength.

This will still be considered false if the maxLength value is not provided.

defaultValue?: string | (() => string)

The default value to use for the TextField or TextArea one initial render. If you want to manually change the value to something else after the initial render, either change the key for the component containing this hook, or use the setState function returned from this hook.

disableMaxLength?: boolean

Boolean if the maxLength prop should not be passed to the TextField component since it will prevent any additional characters from being entered in the text field which might feel like weird behavior to some users. This should really only be used when the counter option is also enabled and rendering along with a FormMessage component.

disableMessage?: boolean

Boolean if the TextField or TextArea will not be rendered along with a FormMessage component. This will prevent the aria-describedby prop from being returned when set to true.

errorIcon?: ReactNode

An optional error icon used in the getErrorIcon option.

getErrorIcon?: GetErrorIcon

A function used to get the error icon to display at the right of the TextField or TextArea. The default behavior will only show an icon when the error state is true and an errorIcon option has been provided.

getErrorMessage?: GetErrorMessage

A function to get and display an error message based on the TextField or TextArea validity. See defaultGetErrorMessage for the default implementation details.

helpText?: ReactNode

An optional help text to display in the FormMessage component when there is not an error.

id: string

The id for the text field. This is required for accessibility.

isErrored?: IsErrored

A function used to determine if the TextField or TextArea is an in errored state. See defaultIsErrored for the default implementation details.

maxLength?: number
minLength?: number
onBlur?: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>
onChange?: FormEventHandler<HTMLInputElement | HTMLTextAreaElement>
onErrorChange?: ErrorChangeHandler

An optional function that will be called whenever the error state is changed. This can be used for more complex forms to disable the Submit button or anything else if any field has an error.

pattern?: string
required?: boolean
theme?: FormTheme

The current theme type.

validateOnChange?: ChangeValidationBehavior

Describes the validation behavior that should be done when the value within the TextField changes. This can either be:

  • a boolean
  • the string "recommended"
  • a single key of the ValidityState that should trigger the validation
  • a list of keys of the ValidityState that should trigger the validation

Generated using TypeDoc