Inputs are text containers which can be used to create forms, enter data, and enact various commands.
Overview
Input is an extremely robust set of components designed to fill many needs throughout an interface. With the ability to have prefixes, suffixes, clear controls, icons, and buttons, Inputs can visually accomplish almost any stylistic need. Inputs also have the ability to have error states, as well as used in coordination with Input Message for hints, validation, and other important contextual feedback.
Inputs contain multiple types, such as "text", "number", "email", "password", "file", "tel", "search", "time", "date", etc.
Sample
Usage
- Text or number entries
- Any type of entry tied to validation
- Data entry
- Form elements
Accessibility
Keyboard navigation
| Key | Function |
|---|---|
Tab | Moves focus in and out of the component. |
Tab and Shift | Moves focus in and out of the component. |
Esc | If the component is focused and clearable with a value - will clear the value. |
API reference
Properties
| Property | Attribute | Description | Type | Default |
|---|---|---|---|---|
| accept | accept | When | string | |
| alignment | alignment | Specifies the text alignment of the component's | Extract<"start" | "end", Alignment> | "start" |
| autocomplete | autocomplete | Specifies the type of content to autocomplete, for use in forms. Read the native attribute's documentation on MDN for more info. | AutoFill | |
| clearable | clearable | When | boolean | false |
| disabled | disabled | When | boolean | false |
| files | When | FileList | undefined | ||
| form | form | Specifies the When not set, the component is associated with its ancestor form element, if one exists. | string | |
| groupSeparator | group-separator | When | boolean | false |
| icon | icon | When | IconName | boolean | |
| iconFlipRtl | icon-flip-rtl | When | boolean | false |
| label | label | Specifies an accessible label for the component. | string | |
| labelText | label-text | Specifies the component's label text. | string | |
| loading | loading | When | boolean | false |
| max | max | When the component resides in a form,
specifies the maximum value for | number | |
| maxLength | max-length | When the component resides in a form,
specifies the maximum length of text for the component's | number | |
| messageOverrides | Overrides individual strings used by the component. | Record<string, unknown> | undefined | ||
| min | min | When the component resides in a form,
specifies the minimum value for | number | |
| minLength | min-length | When the component resides in a form,
specifies the minimum length of text for the component's | number | |
| multiple | multiple | When | boolean | false |
| name | name | Specifies the name of the component. Required to pass the component's | string | |
| numberButtonType | number-button-type | When | InputPlacement | "vertical" |
| numberingSystem | numbering-system | Specifies the Unicode numeral system used by the component for localization. | NumberingSystem | |
| pattern | pattern | When the component resides in a form,
specifies a regular expression (regex) pattern the component's | string | |
| placeholder | placeholder | Specifies the component's placeholder text. | string | |
| prefixText | prefix-text | Specifies text to display at the start of the component. | string | |
| readOnly | read-only | When | boolean | false |
| required | required | When | boolean | false |
| scale | scale | Specifies the size of the component. | Scale | "m" |
| status | status | Specifies the input field's status, which determines message and icons. | Status | "idle" |
| step | step | Specifies the granularity the component's | number | "any" | |
| suffixText | suffix-text | Specifies text to display at the end of the component. | string | |
| type | type | Specifies the component type. Note that the following | "color" | "date" | "datetime-local" | "email" | "file" | "image" | "month" | "number" | "password" | "search" | "tel" | "text" | "time" | "url" | "week" | "text" |
| validationIcon | validation-icon | Specifies the validation icon to display under the component. | IconName | boolean | |
| validationMessage | validation-message | Specifies the validation message to display under the component. | string | |
| validity | The component's current validation state. | ValidityState | ||
| value | value | The component's value. | string |
Slots
| Name | Description |
|---|---|
| action | A slot for positioning a |
| label-content | A slot for rendering content next to the component's |
Styles
| Name | Description |
|---|---|
| --calcite-input-prefix-size | When |
| --calcite-input-suffix-size | When |
| --calcite-input-prefix-text-color | When |
| --calcite-input-suffix-text-color | When |
| --calcite-input-background-color | Specifies the component's background color. |
| --calcite-input-border-color | Specifies the component's border color. |
| --calcite-input-corner-radius | Specifies the component's corner radius. |
| --calcite-input-shadow | Specifies the component's shadow. |
| --calcite-input-icon-color | Specifies the component's |
| --calcite-input-text-color | Specifies the component's text color. |
| --calcite-input-placeholder-text-color | Specifies the component's placeholder text color. |
| --calcite-input-actions-background-color | Specifies the background color of the component's |
| --calcite-input-actions-background-color-hover | Specifies the background color of the component's |
| --calcite-input-actions-background-color-press | Specifies the background color of the component's |
| --calcite-input-actions-icon-color | Specifies the icon color of the component's |
| --calcite-input-actions-icon-color-hover | Specifies the icon color of the component's |
| --calcite-input-actions-icon-color-press | Specifies the icon color of the component's |
| --calcite-input-loading-background-color | When |
| --calcite-input-loading-fill-color | When |
Events
| Name | Description | Behavior |
|---|---|---|
| calciteInputChange | Fires each time a new | |
| calciteInputInput | Fires each time a new |
Methods
| Name | Description | Signature |
|---|---|---|
| componentOnReady | Creates a promise that resolves once the component is fully loaded. | componentOnReady(): Promise<this> |
| selectText | Selects the text of the component's | selectText(): Promise<void> |
| setFocus | Sets focus on the component. | setFocus(options?: FocusOptions): Promise<void> |