Interface FormFieldProps<ComponentProps, Component>

Specific behaviour/configuration this form field should conform to.

Type Parameters

Hierarchy

  • FormFieldProps

Properties

as: ComponentType<ComponentProps>
autocomplete?: FormInputAutocomplete

Instructs the browser how to autocomplete this field.

See

Example

{
type: FormInputAutocompleteTypes.CURRENT_PASSWORD
}
children?: ReactNode
defaultValue?: string

Prefilled value for the field. This will be passed to the component you pass.

disabled?: boolean

Whether this field is disabled. The value will still be sent to onSubmit.

Default

false

error?: null | string

Supply your own error message if needed.

id: string

Unique ID for this field.

Required

inputProps?: Component extends ComponentType<P> ? P : ComponentProps
label?: string

Textual label for this field. It's recommended to keep this for accessibility.

placeholder?: string

Provide an example or specific instructions to the user, or use this as a less accessible but sometimes cleaner label.

Example

"Enter an email address"
required?: boolean

Whether this field is required from a user.

Default

false

schema?: Partial<LengthValidator & StringValidator>

Basic schema for the value.

Example

{ // length must be greater than 3
gt: 3
}
setValue?: ((value: string) => void)

Type declaration

    • (value: string): void
    • Parameters

      • value: string

      Returns void

validate?: ((value: string) => void)

Type declaration

    • (value: string): void
    • Custom function to validate the input. The function must throw an error or it will be assumed the value passes validation.

      Example

      (value) => {
      if (value === 'wrong') throw "Incorrect answer."
      }

      Parameters

      • value: string

      Returns void

value?: string

Generated using TypeDoc