skip to content

Input

The Input component lets users enter information directly into a field.

Demo

<div class="eds-c-form">
{{> eds-c-input}}
</div>

When to use this component

Use the Input component to let users enter text, number, URL, password or search information.

How it works

To use the Input component, you also have to use the Form component.

Installation

To install the components, go to the get started guide for developers.

To use the Input component, enter the following command in your Terminal:

npm install @springernature/elements

Styles

All form components require some other components to work correctly. These enable the label, hint, error summary message and error summary.

To use the Input component, require the styles of the following components in the following order:

@import '../path/to/node_modules/@springernature/elements/components/eds-c-form;
@import '../path/to/node_modules/@springernature/elements/components/eds-c-error-summary;
@import '../path/to/node_modules/@springernature/elements/components/eds-c-label;
@import '../path/to/node_modules/@springernature/elements/components/eds-c-hint;
@import '../path/to/node_modules/@springernature/elements/components/eds-c-error-message;

The Input component uses common input style rules defined in the Form component and doesn't have any specific styles.

Templates

Use the input component together with the EDS Form component.

Use the form template and read the schema file.

You can pass the Input component in the inputs array as many times as you need.

Configuration

Use the Input component for the following types:

  • text
  • password
  • email
  • tel
  • hidden
  • search
  • number
  • url

We are working on separate components for other input types such as checkboxes or radios.

For the submit button of your form, use the Button component.

Properties

For more detailed information on how to use the properties correctly, go to the schema file.

Input can be block, which is the default, or inline.

For more information on the inline input object shape, go to the schema file.

The inline input has an inlineInputs array. Here you can pass the input objects you need. On every inline input object, set the uiSettings.inline property to true.

The Input component uses other components such as label, hint and error message.

The error message requires the errorPrefix property. This must be a string with a value of “Error:”. This is to clearly identify errors to screen reader users.

If you want to visually hide “Error:” from your error message, you can set the property screenReaderOnlyErrorPrefix to true. This will hide it visually, but will keep it available for screen reader users.

Name Description Required
inputId [string] the id of the input
inputType [string] one of the above types
name [string]
value [string]
label [object] see eds-c-label schema file and eds-c-hint schema file
required [boolean]
disabled [boolean]
error [object] see eds-c-error-message schema file
hidden [boolean]
readonly [boolean]
max [number]
maxlength [number]
minlength [number]
autocomplete [boolean]
novalidate [boolean]
multiple [boolean]
pattern [string]
datalist [object]
dataAttributes [object]
buttons [object] see eds-c-button schema file
uiSettings [object] contains the visual settingd for the user interface.

Help improve this page

If you’ve got a question, idea or suggestion about how to improve this component or guidance,
post in the #ask-elements Slack channel.