Skip to main content

Input

<ui5-input>

The ui5-input component allows the user to enter and edit text or numeric values in one line.

Additionally, you can provide suggestionItems, that are displayed in a popover right under the input.

The text field can be editable or read-only (readonly property), and it can be enabled or disabled (disabled property). To visualize semantic states, such as "Negative" or "Critical", the valueState property is provided. When the user makes changes to the text, the change event is fired, which enables you to react on any text change.

Keyboard Handling

The ui5-input provides the following keyboard shortcuts:

  • [Escape] - Closes the suggestion list, if open. If closed or not enabled, cancels changes and reverts to the value which the Input field had when it got the focus.
  • [Enter] or [Return] - If suggestion list is open takes over the current matching item and closes it. If value state or group header is focused, does nothing.
  • [Down] - Focuses the next matching item in the suggestion list. Selection-change event is fired.
  • [Up] - Focuses the previous matching item in the suggestion list. Selection-change event is fired.
  • [Home] - If focus is in the text input, moves caret before the first character. If focus is in the list, highlights the first item and updates the input accordingly.
  • [End] - If focus is in the text input, moves caret after the last character. If focus is in the list, highlights the last item and updates the input accordingly.
  • [Page Up] - If focus is in the list, moves highlight up by page size (10 items by default). If focus is in the input, does nothing.
  • [Page Down] - If focus is in the list, moves highlight down by page size (10 items by default). If focus is in the input, does nothing.
  • [Ctrl]+[Alt]+[F8] or [Command]+[Option]+[F8] - Focuses the first link in the value state message, if available. Pressing [Tab] moves the focus to the next link in the value state message, or closes the value state message if there are no more links.

ES6 Module Import

import "@ui5/webcomponents/dist/Input.js";

Basic Sample

Properties

disabled

DescriptionDefines whether the component is in disabled state.
Note: A disabled component is completely noninteractive.
Typeboolean
Defaultfalse

placeholder

DescriptionDefines a short hint intended to aid the user with data entry when the component has no value.
Typestring | undefined
Defaultundefined

readonly

DescriptionDefines whether the component is read-only.
Note: A read-only component is not editable, but still provides visual feedback upon user interaction.
Typeboolean
Defaultfalse

required

DescriptionDefines whether the component is required.
Typeboolean
Defaultfalse
Since1.0.0-rc.3

noTypeahead

DescriptionDefines whether the value will be autcompleted to match an item
Typeboolean
Defaultfalse
Since1.4.0

type

DescriptionDefines the HTML type of the component.
Notes:
- The particular effect of this property differs depending on the browser and the current language settings, especially for type Number.
- The property is mostly intended to be used with touch devices that use different soft keyboard layouts depending on the given input type.
Type"Text" | "Email" | "Number" | "Password" | "Tel" | "URL" | "Search"
Default"Text"

value

DescriptionDefines the value of the component.
Note: The property is updated upon typing.
Typestring
Default""

valueState

DescriptionDefines the value state of the component.
Type"None" | "Positive" | "Critical" | "Negative" | "Information"
Default"None"

name

DescriptionDetermines the name by which the component will be identified upon submission in an HTML form.
Note: This property is only applicable within the context of an HTML Form element.
Typestring | undefined
Defaultundefined

showSuggestions

DescriptionDefines whether the component should show suggestions, if such are present.
Typeboolean
Defaultfalse

maxlength

DescriptionSets the maximum number of characters available in the input field.
Note: This property is not compatible with the ui5-input type InputType.Number. If the ui5-input type is set to Number, the maxlength value is ignored.
Typenumber | undefined
Defaultundefined
Since1.0.0-rc.5

accessibleName

DescriptionDefines the accessible ARIA name of the component.
Typestring | undefined
Defaultundefined
Since1.0.0-rc.15

accessibleNameRef

DescriptionReceives id(or many ids) of the elements that label the input.
Typestring | undefined
Defaultundefined
Since1.0.0-rc.15

accessibleDescription

DescriptionDefines the accessible description of the component.
Typestring | undefined
Defaultundefined
Since2.9.0

accessibleDescriptionRef

DescriptionReceives id(or many ids) of the elements that describe the input.
Typestring | undefined
Defaultundefined
Since2.9.0

showClearIcon

DescriptionDefines whether the clear icon of the input will be shown.
Typeboolean
Defaultfalse
Since1.2.0

open

DescriptionDefines whether the suggestions picker is open. The picker will not open if the showSuggestions property is set to false, the input is disabled or the input is readonly. The picker will close automatically and close event will be fired if the input is not in the viewport.
Typeboolean
Defaultfalse
Since2.0.0

Slots

default

DescriptionDefines the suggestion items.
Note: The suggestions would be displayed only if the showSuggestions property is set to true.
Note: The <ui5-suggestion-item>, <ui5-suggestion-item-group> and ui5-suggestion-item-custom are recommended to be used as suggestion items.
TypeArray<IInputSuggestionItem>

icon

DescriptionDefines the icon to be displayed in the component.
TypeArray<IIcon>

valueStateMessage

DescriptionDefines the value state message that will be displayed as pop up under the component. The value state message slot should contain only one root element.
Note: If not specified, a default text (in the respective language) will be displayed.
Note: The valueStateMessage would be displayed, when the component is in Information, Critical or Negative value state.
Note: If the component has suggestionItems, the valueStateMessage would be displayed as part of the same popover, if used on desktop, or dialog - on phone.
TypeArray<HTMLElement>
Since1.0.0-rc.6

Events

change

DescriptionFired when the input operation has finished by pressing Enter or on focusout.
TypeCustomEvent
BubblesYes
CancelableNo

input

DescriptionFired when the value of the component changes at each keystroke, and when a suggestion item has been selected.
TypeCustomEvent
BubblesYes
CancelableYes - via preventDefault()

select

DescriptionFired when some text has been selected.
TypeCustomEvent
Since2.0.0
BubblesYes
CancelableNo

selection-change

DescriptionFired when the user navigates to a suggestion item via the ARROW keys, as a preview, before the final selection.
TypeCustomEvent<InputSelectionChangeEventDetail>
Parametersitem: HTMLElement
The previewed suggestion item.
Since2.0.0
BubblesYes
CancelableNo

open

DescriptionFired when the suggestions picker is open.
TypeCustomEvent
Since2.0.0
BubblesYes
CancelableNo

close

DescriptionFired when the suggestions picker is closed.
TypeCustomEvent
Since2.0.0
BubblesNo
CancelableNo

Methods

No methods available for this component.

CSS Parts

NameDescription
rootUsed to style the root DOM element of the Input component
inputUsed to style the native input element
clear-iconUsed to style the clear icon, which can be pressed to clear user input text

More Samples

Clear Icon

The Input can show a clear icon, visble when there is a value, typed by the user. When pressed, the value gets cleared.

Input with Suggestions

The Input can show dropdown with suggestions upon user input - see the showSuggestions property for more information.

Suggestions Wrapping

The sample demonstrates how the text of the suggestions wrap when too long.

Input and Label

Value State Message

Value-help Dialog

Custom Suggestions

Custom Styling

To some extent, the Input allows customization with pure CSS as shown in the sample.