Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface TextFieldHookOptions

remarks

@since 2.5.0

Hierarchy

Index

Properties

Optional counter

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.

Optional defaultValue

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.

Optional disableMaxLength

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.

Optional disableMessage

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.

Optional errorIcon

errorIcon: ReactNode

An optional error icon used in the getErrorIcon option.

Optional getErrorIcon

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.

Optional getErrorMessage

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.

Optional helpText

helpText: ReactNode

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

id

id: string

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

Optional isErrored

isErrored: IsErrored

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

Optional maxLength

maxLength: number

Optional minLength

minLength: number

Optional onBlur

onBlur: FocusEventHandler<HTMLInputElement | HTMLTextAreaElement>

Optional onChange

onChange: FormEventHandler<HTMLInputElement | HTMLTextAreaElement>

Optional onErrorChange

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.

Optional pattern

pattern: string

Optional required

required: boolean

Optional theme

theme: FormTheme

The current theme type.

Optional validateOnChange

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