#Overview

Input Fields are used with Forms (Code).

#Text Field

Show codeHide code
export const TextFieldDemo = () => {
  const form = useForm<{ textField: string }>();
  return (
    <form onSubmit={form.handleSubmit(() => {})}>
      <TextField
        form={form}
        name="textField"
        label="A text between 10 and 50 characters"
        options={{
          required: {
            value: true,
            message: "Please provide a text between 10 and 50 characters",
          },
          minLength: {
            value: 10,
            message:
              "Choose a text that is equal or longer than 10 characters.",
          },
          maxLength: {
            value: 50,
            message: "Choose a text that is shorter or equal to 50 characters.",
          },
        }}
      />
      <Button type="submit">Submit</Button>
    </form>
  );
};

NameTypeDefaultDescription
form *UseFormReturn<TFieldValues>
-

The connected form that the form field is part of

name *TFieldName
-

The name of the input being registered from the form

defaultValuenumber | string
-

The default value of the input field

disabledboolean
-

If true, the input field is disabled

hasErrorboolean
-

If true, turns the border red

helpTextReactNode
-

A help text that can be displayed below the input field

hideHelpAndValidationboolean

false

Hides the help text and validation message

iconAfterFunctionComponent<IIconProps>
-

The icon after the input text

iconBeforeFunctionComponent<IIconProps>
-

The icon before the input text

labelReactNode
-

The label of the input field

labelOptionalAppendixReactNode
-

Marker inside the label, when the field is optional

labelRequiredAppendixReactNode
-

Marker inside the label, when the field is required

noWrapboolean
-
onChangeChangeEventHandler<HTMLInputElement>
-

The change event handler

optionsTBase extends unknown ? Omit<TBase, TKey> : never

{ required: { value: true, message: __("Required") } }

The options that can be set for the registration of the field

placeholderstring
-

A hint for the expected value

type"email" | "number" | "password" | "search" | "tel" | "text" | "url"

"text"

Set the type of input field

#Multi Line Text Field

Field for several lines of text.

Show codeHide code
export const MultiLineTextFieldDemo = () => {
  const form = useForm<{ textField: string }>();
  const maxLength = 300;
  const [currentLength, setCurrentLength] = useState(0);

  return (
    <form onSubmit={form.handleSubmit(() => {})}>
      <MultiLineTextField
        form={form}
        name="textField"
        label="Long text with limit"
        helpText={`${currentLength}/${maxLength} Characters`}
        onChange={(e) => setCurrentLength(e.target.value.length || 0)}
        options={{
          required: { value: true, message: "Value is required" },
          maxLength: {
            value: maxLength,
            message: `${currentLength}/${maxLength} Characters`,
          },
        }}
      />
      <Button type="submit">Submit</Button>
    </form>
  );
};

NameTypeDefaultDescription
form *UseFormReturn<TFieldValues>
-

The connected form that the form field is part of

name *TFieldName
-

The name of the input being registered from the form

defaultValuestring
-

The default value of the input field

disabledboolean
-

If true, the input field is disabled

hasErrorboolean
-

If true, turns the border red

helpTextReactNode
-

A help text that can be displayed below the input field

hideHelpAndValidationboolean

false

Hides the help text and validation message

labelReactNode
-

The label of the input field

labelOptionalAppendixReactNode
-

Marker inside the label, when the field is optional

labelRequiredAppendixReactNode
-

Marker inside the label, when the field is required

noWrapboolean
-
onChangeChangeEventHandler<HTMLTextAreaElement>
-

The change event handler

optionsTBase extends unknown ? Omit<TBase, TKey> : never

{ required: { value: true, message: __("Required") } }

The options that can be set for the registration of the field

placeholderstring
-

A hint for the expected value

rowsnumber

2

The initial amount of visible lines

#Number and Decimal Field

Fields to either enter a numeric or a decimal value. The input mode is changed fore these fields but type="number" is not set intentionally as it locks the keyboard and blocks feedback for typing characters. Validation should always give feedback and users should be allowed to type freely.

Show codeHide code
export const NumberTextFieldDemo = () => {
  const form = useForm<{ textField: string }>();
  return (
    <form onSubmit={form.handleSubmit(() => {})} noValidate>
      <NumberTextField
        form={form}
        name="textField"
        label="A number between 2 and 10"
        options={{
          required: {
            value: true,
            message: "Please provide a number between 2 and 10",
          },
          min: {
            value: 2,
            message: "Choose a number that is greater or equal to 2.",
          },
          max: {
            value: 10,
            message: "Choose a number, that is smaller or equal to ten.",
          },
        }}
      />
      <Button type="submit">Submit</Button>
    </form>
  );
};

Show codeHide code
export const DecimalTextFieldDemo = () => {
  const form = useForm<{ textField: string }>();
  return (
    <form onSubmit={form.handleSubmit(() => {})} noValidate>
      <DecimalTextField
        step={0.05}
        form={form}
        name="textField"
        label="A number between 0 and 1"
        options={{
          required: {
            value: true,
            message: "Please provide a number between 0 and 1",
          },
          min: {
            value: 0,
            message: "Choose a number that is greater or equal to 0.",
          },
          max: {
            value: 1,
            message: "Choose a number, that is smaller or equal to 1.",
          },
        }}
      />
      <Button type="submit">Submit</Button>
    </form>
  );
};

#Phone Number Text Field

Accessibility complete and browser auto-fill ready phone number field. With international phone number validation.

Show codeHide code
export const PhoneNumberTextFieldDemo = () => {
  const form = useForm<{ phoneNumber?: string }>({ mode: "onBlur" });

  return (
    <form onSubmit={form.handleSubmit(() => {})}>
      <PhoneNumberTextField
        form={form}
        name="phoneNumber"
        options={{ required: false }}
      />
      <Button type="submit">Submit</Button>
    </form>
  );
};

#Checked Text Field

Built-in visual representation of valid input, through a checkmark, when the field was touched and validates.

When setting up the form, set the mode to onBlur, onChange, onTouched or all. Otherwise the field will display a checkmark once the field is touched but may be invalidated once the user tries to submit the form.

Show codeHide code
export const CheckedTextFieldDemo = () => {
  const form = useForm<{ email: string }>({ mode: "onBlur" });
  return (
    <form onSubmit={form.handleSubmit(() => {})}>
      <CheckedTextField
        form={form}
        name="email"
        label="Email"
        options={{
          required: { value: true, message: "Value is required" },
          pattern: {
            value: /\S+@\S+\.\S+/,
            message: "Please provide a valid email address",
          },
        }}
      />
      <Button type="submit">Submit</Button>
    </form>
  );
};

NameTypeDefaultDescription
form *UseFormReturn<TFieldValues>
-

The connected form that the form field is part of

name *TFieldName
-

The name of the input being registered from the form

defaultValuenumber | string
-

The default value of the input field

disabledboolean
-

If true, the input field is disabled

hasErrorboolean
-

If true, turns the border red

helpTextReactNode
-

A help text that can be displayed below the input field

hideHelpAndValidationboolean

false

Hides the help text and validation message

iconBeforeFunctionComponent<IIconProps>
-

The icon before the input text

labelReactNode
-

The label of the input field

labelOptionalAppendixReactNode
-

Marker inside the label, when the field is optional

labelRequiredAppendixReactNode
-

Marker inside the label, when the field is required

noWrapboolean
-
onChangeChangeEventHandler<HTMLInputElement>
-

The change event handler

optionsTBase extends unknown ? Omit<TBase, TKey> : never

{ required: { value: true, message: __("Required") } }

The options that can be set for the registration of the field

placeholderstring
-

A hint for the expected value

type"email" | "number" | "password" | "search" | "tel" | "text" | "url"

"text"

Set the type of input field

#Checked Autocomplete Text Field

The Checked Autocomplete Text Field lets you select a suggestion based on your input. When registering the form, use the same mode as suggested for the Checked Text Field.

Read Dropdown (Code) to understand how suggestion items can be added to the field.

Show codeHide code
export const CheckedAutocompleteTextFieldDemo = () => {
  const form = useForm<{ fruits: string }>();
  return (
    <form onSubmit={form.handleSubmit(() => {})}>
      <CheckedAutocompleteTextField
        form={form}
        name="fruits"
        label="Favourite Fruit"
        items={fruitOptions}
        minCharactersForSuggestion={1}
        options={{
          required: {
            value: true,
            message: "Please provide a value",
          },
        }}
      />
      <Button type="submit">Send</Button>
    </form>
  );
};

NameTypeDefaultDescription
form *UseFormReturn<TFieldValues>
-

The connected form that the form field is part of

items *Array<ISelectOption>
-

The selectable items

name *TFieldName
-

The name of the input being registered from the form

defaultValuenumber | string
-

The default value of the input field

disabledboolean
-

If true, the input field is disabled

hasErrorboolean
-

If true, turns the border red

helpTextReactNode
-

A help text that can be displayed below the input field

hideHelpAndValidationboolean
-

Hides the help text and validation message

iconBeforeFunctionComponent<IIconProps>
-

The icon before the input text

itemToString(item: ISelectOption) => string

(item) => item?.label ?? ""

Parse function to convert the selected into into a string to show inside the input field

labelReactNode
-

The label of the input field

labelOptionalAppendixReactNode
-

Marker inside the label, when the field is optional

labelRequiredAppendixReactNode
-

Marker inside the label, when the field is required

minCharactersForSuggestionnumber

2

The minimal amount of characters needed to show suggestions

noWrapboolean
-
onBlurChangeEventHandler<HTMLInputElement>
-

Callback the input field is blurred

onChangeChangeEventHandler<HTMLInputElement>
-

Callback when the selected item changes and when input changes

onInputValueChange(inputValue: string) => Promise<void>
-

An optional callback to filter items asynchronous - useful to fetch an API again

onMenuClose() => void
-

Callback when the menu closes

onMenuOpen() => void
-

Callback when the menu opens

onSelectChangeEventHandler<HTMLInputElement>
-

Callback when the selected item changes

optionsTBase extends unknown ? Omit<TBase, TKey> : never

{ required: { value: true, message: __("Required") } }

The options that can be set for the registration of the field

placeholderstring
-

A hint for the expected value

type"email" | "number" | "password" | "search" | "tel" | "text" | "url"

"text"

Set the type of input field

#Max Length Text Field

A Text Field and Multi Line Text Field that will show a character count once a user types 85% of the allowed number of characters. It will show a validation error if the form is validated and the max length is exceeded.

Show codeHide code
export const MaxLengthTextFieldDemo = () => {
  const form = useForm<{ text: string }>({
    defaultValues: { text: "Some existing text" },
  });
  return (
    <form onSubmit={form.handleSubmit(() => {})}>
      <MaxLengthTextField form={form} name="text" maxLength={70} />
      <Button type="submit">Submit</Button>
    </form>
  );
};

Show codeHide code
export const MaxLengthMultiLineTextFieldDemo = () => {
  const form = useForm<{ text: string }>({ mode: "onSubmit" });
  return (
    <form onSubmit={form.handleSubmit(() => {})}>
      <MaxLengthMultiLineTextField form={form} name="text" maxLength={200} />
      <ButtonGroup>
        <Button onClick={() => form.reset()}>Reset</Button>
        <Button variant="primary" type="submit">
          Submit
        </Button>
      </ButtonGroup>
    </form>
  );
};

#Outside of forms

#Input Field

NameTypeDefaultDescriptionControls
defaultValuenumber | string
-

The default value of the input field

disabledboolean
-

If true, the input field is disabled

hasErrorboolean
-

If true, turns the border red

iconAfterFunctionComponent<IIconProps>
-

The icon after the input text

iconBeforeFunctionComponent<IIconProps>
-

The icon before the input text

onChangeChangeEventHandler<HTMLInputElement>
-

The change event handler

-
placeholderstring
-

A hint for the expected value

type"email" | "number" | "password" | "search" | "tel" | "text" | "url"

"text"

Set the type of input field

valuenumber | string
-

The value of the input field

#Multi Line Input Field

NameTypeDefaultDescriptionControls
defaultValuestring
-

The default value of the input field

disabledboolean
-

If true, the input field is disabled

hasErrorboolean
-

If true, turns the border red

onChangeChangeEventHandler<HTMLTextAreaElement>
-

The change event handler

-
placeholderstring
-

A hint for the expected value

rowsnumber

2

The initial amount of visible lines

valuestring
-

The value of the input field

#Checked Input Field

Checked Input Fields add a Checkmark at the end of the field to make it more obvious that the validation was successful.

NameTypeDefaultDescriptionControls
isChecked *boolean
-

If true, a checkmark at the end of the field is displayed

defaultValuenumber | string
-

The default value of the input field

disabledboolean
-

If true, the input field is disabled

hasErrorboolean
-

If true, turns the border red

iconBeforeFunctionComponent<IIconProps>
-

The icon before the input text

-
onChangeChangeEventHandler<HTMLInputElement>
-

The change event handler

-
placeholderstring
-

A hint for the expected value

type"email" | "number" | "password" | "search" | "tel" | "text" | "url"

"text"

Set the type of input field

valuenumber | string
-

The value of the input field

#Checked Autocomplete Input Field

The Checked Autocomplete Input Field lets you select a suggestion based on your input. Additionally, it adds a Checkmark at the end of the field to make it more obvious that the validation was successful.

NameTypeDefaultDescriptionControls
isChecked *boolean
-

If true, a checkmark at the end of the field is displayed

items *Array<ISelectOption>
-

The selectable items

-
defaultValuenumber | string
-

The default value of the input field

disabledboolean
-

If true, the input field is disabled

hasErrorboolean
-

If true, turns the border red

iconBeforeFunctionComponent<IIconProps>
-

The icon before the input text

-
itemToString(item: ISelectOption) => string

(item) => item?.label ?? ""

Parse function to convert the selected into into a string to show inside the input field

-
minCharactersForSuggestionnumber

2

The minimal amount of characters needed to show suggestions

onBlurChangeEventHandler<HTMLInputElement>
-

Callback the input field is blurred

-
onChangeChangeEventHandler<HTMLInputElement>
-

Callback when the selected item changes and when input changes

-
onInputValueChange(inputValue: string) => Promise<void>
-

An optional callback to filter items asynchronous - useful to fetch an API again

-
onMenuClose() => void
-

Callback when the menu closes

-
onMenuOpen() => void
-

Callback when the menu opens

-
onSelectChangeEventHandler<HTMLInputElement>
-

Callback when the selected item changes

-
placeholderstring
-

A hint for the expected value

type"email" | "number" | "password" | "search" | "tel" | "text" | "url"

"text"

Set the type of input field

valuestring
-

The value of the input field

#Colors

  • Token
  • CHECKMARK#280#8d6#1a3#4c4
  • FIELD_BACKGROUND#fff#111#fff#111
  • FIELD_BACKGROUND_DISABLED#0000#fff1#0000#fff1
  • FIELD_BACKGROUND_ERROR#fff#111#fff#111
  • FIELD_BACKGROUND_FILLED#fff#111#fff#111
  • FIELD_BACKGROUND_FOCUS#fff#111#fff#111
  • FIELD_BORDER#bbb#fff4#bbb#fff4
  • FIELD_BORDER_DISABLED#0001#fff1#0001#fff1
  • FIELD_BORDER_ERROR#f75#f75#e02#f55
  • FIELD_BORDER_FILLED#bbb#fff4#bbb#fff4
  • FIELD_BORDER_FOCUS#555#fff#059#fff
  • HELP_TEXT#0009#fffb#0009#fffb
  • HELP_TEXT_DISABLED#0009#fffb#0009#fffb
  • HELP_TEXT_ERROR#c42#f75#e02#f44
  • HELP_TEXT_FILLED#0009#fffb#0009#fffb
  • HELP_TEXT_FOCUS#0009#fffb#0009#fffb
  • ICONAFTER_BACKGROUND#000d#fffb#000d#fffb
  • ICONAFTER_BACKGROUND_DISABLED#0004#fff4#0004#fff4
  • ICONAFTER_BACKGROUND_ERROR#000d#fffb#000d#fffb
  • ICONAFTER_BACKGROUND_FILLED#000d#fffb#000d#fffb
  • ICONAFTER_BACKGROUND_FOCUS#000d#fffb#000d#fffb
  • ICONAFTER_FIELD_BACKGROUND_DISABLED#fff#111#fff#111
  • ICONBEFORE_BACKGROUND#000d#fffb#000d#fffb
  • ICONBEFORE_BACKGROUND_DISABLED#0004#fff4#0004#fff4
  • ICONBEFORE_BACKGROUND_ERROR#000d#fffb#000d#fffb
  • ICONBEFORE_BACKGROUND_FILLED#000d#fffb#000d#fffb
  • ICONBEFORE_BACKGROUND_FOCUS#000d#fffb#000d#fffb
  • LABEL_TEXT#0009#fffb#0009#fffb
  • LABEL_TEXT_DISABLED#0009#fffb#0009#fffb
  • LABEL_TEXT_ERROR#0009#fffb#0009#fffb
  • LABEL_TEXT_FILLED#0009#fffb#0009#fffb
  • LABEL_TEXT_FOCUS#0009#fffb#0009#fffb
  • VALUE_TEXT#0004#fff4#0004#fff4
  • VALUE_TEXT_DISABLED#0004#fff4#0004#fff4
  • VALUE_TEXT_ERROR#000#fff#000#fff
  • VALUE_TEXT_FILLED#000#fff#000#fff
  • VALUE_TEXT_FOCUS#000#fff#000#fff