A single-line text field to enter and edit data. It supports prefix and suffix content, helper text, form integration and built-in validation.
- Element
-
igc-input
- Slots
-
prefix— Renders content before the input. -
suffix— Renders content after the input. -
helper-text— Renders content below the input. -
value-missing— Renders content when the required validation fails. -
type-mismatch— Renders content when the url/email type validation fails. -
pattern-mismatch— Renders content when the pattern validation fails. -
too-long— Renders content when the maxlength validation fails. -
too-short— Renders content when the minlength validation fails. -
range-overflow— Renders content when the max validation fails. -
range-underflow— Renders content when the min validation fails. -
step-mismatch— Renders content when the step validation fails. -
custom-error— Renders content when a custom message is set with `setCustomValidity()`. -
invalid— Renders content when the component is in invalid state (validity.valid = false).
- CSS Parts
-
container— The main wrapper that holds all main input elements. -
input— The native input element. -
label— The native label element. -
prefix— The prefix wrapper. -
suffix— The suffix wrapper. -
helper-text— The helper text wrapper. -
prefixed— Added to the container and the input when an element that is not hidden is in the prefix slot. -
suffixed— Added to the container and the input when an element that is not hidden is in the suffix slot. -
filled— Added to the container and the input when the control has a value. -
labelled— Added to the container in the material theme when the control has a label. -
start— The wrapper of the prefix in the material theme. -
notch— The wrapper of the label in the material theme. -
filler— The outline segment between the notch and the end in the material theme. -
end— The wrapper of the suffix in the material theme.
Properties
Section titled "Properties"autocomplete
Section titled "autocomplete"A hint for the browser on how to autofill the control.
autocomplete: string Defined in src/components/input/input.ts:222
autofocus
Section titled "autofocus"Whether the control receives focus automatically.
autofocus: boolean Defined in src/components/input/input.ts:215
disabled
Section titled "disabled"Inherited from: IgcInputBaseComponent
Whether the control is disabled. A disabled control is not validated, and the form does not submit its value.
disabled: boolean Defined in src/internals/mixins/forms/types.ts:35
inputMode
Section titled "inputMode"A hint to the browser for which virtual keyboard layout to display. See relevant MDN article
inputMode: string Defined in src/components/input/input.ts:160
invalid
Section titled "invalid"Inherited from: IgcInputBaseComponent
Whether the control shows the invalid state. It changes only the visual state, not the validity.
invalid: boolean Defined in src/internals/mixins/forms/types.ts:43
label
Section titled "label"Inherited from: IgcInputBaseComponent
The label for the control.
label: string Defined in src/components/input/input-base.ts:87
Optional max
Section titled "max"The maximum value the control accepts.
max: number = undefined Defined in src/components/input/input.ts:200
Optional maxLength
Section titled "maxLength"The maximum string length of the control.
maxLength: number = undefined Defined in src/components/input/input.ts:184
Optional min
Section titled "min"The minimum value the control accepts.
min: number = undefined Defined in src/components/input/input.ts:192
Optional minLength
Section titled "minLength"The minimum string length required by the control.
minLength: number = undefined Defined in src/components/input/input.ts:176
Inherited from: IgcInputBaseComponent
The name of the control, submitted with the form data.
name: string Defined in src/internals/mixins/forms/types.ts:49
outlined
Section titled "outlined"Inherited from: IgcInputBaseComponent
Whether the control has an outlined appearance.
outlined: boolean = false Defined in src/components/input/input-base.ts:73
Optional pattern
Section titled "pattern"The regular expression the value is validated against.
pattern: string = undefined Defined in src/components/input/input.ts:168
placeholder
Section titled "placeholder"Inherited from: IgcInputBaseComponent
The placeholder text of the control.
placeholder: string Defined in src/components/input/input-base.ts:80
readOnly
Section titled "readOnly"Whether the control is read-only.
readOnly: boolean = false Defined in src/components/input/input.ts:152
Optional step
Section titled "step"The granularity the value must adhere to.
step: number = undefined Defined in src/components/input/input.ts:208
validateOnly
Section titled "validateOnly"Whether the validation rules apply without restricting user input. The user can type past maxLength,
and the spin buttons of a number input can go past min and max.
validateOnly: boolean = false Defined in src/components/input/input.ts:232
styles
Section titled "styles"Array of styles to apply to the element. The styles should be defined using the css tag function, via constructible stylesheets, or imported from native CSS module scripts.
Note on Content Security Policy:
Element styles are implemented with <style> tags when the browser doesn't
support adopted StyleSheets. To use such <style> tags with the style-src
CSP directive, the style-src value must either include 'unsafe-inline' or
nonce-<base64-value> with <base64-value> replaced be a server-generated
nonce.
To provide a nonce to use on generated <style> elements, set
window.litNonce to a server-generated nonce in your page's HTML, before
loading application code:
``
styles: CSSResult[] Defined in src/components/input/input.ts:90
Accessors
Section titled "Accessors"defaultValue
Section titled "defaultValue"Inherited from: IgcInputBaseComponent
get defaultValue(): any Defined in src/internals/mixins/forms/types.ts:158
The default value of the control. A form reset restores the value to it.
While the value is unchanged since the start or the last form reset, a new
default also sets the value. The value attribute also sets it.
set defaultValue(value: unknown): void Defined in src/internals/mixins/forms/types.ts:158
Parameters
- value:
unknown
Returns void
Inherited from: IgcInputBaseComponent
The form that the control is associated with, or null.
get form(): HTMLFormElement | null Defined in src/internals/mixins/forms/types.ts:52
Returns HTMLFormElement | null
required
Section titled "required"Inherited from: IgcInputBaseComponent
get required(): any Defined in src/internals/mixins/forms/types.ts:188
Whether the control is required. A required control that has no value, or is not checked, fails validation.
set required(value: boolean): void Defined in src/internals/mixins/forms/types.ts:188
Parameters
- value:
boolean
Returns void
selectionEnd
Section titled "selectionEnd"The offset of the end of the text selection, in UTF-16 code units.
null before the first render and for the email and number types.
get selectionEnd(): number | null Defined in src/components/input/input.ts:247
Returns number | null
selectionStart
Section titled "selectionStart"The offset of the start of the text selection, in UTF-16 code units.
Equals selectionEnd when no text is selected. null before the first
render and for the email and number types, which have no selection.
get selectionStart(): number | null Defined in src/components/input/input.ts:239
Returns number | null
validationMessage
Section titled "validationMessage"Inherited from: IgcInputBaseComponent
The validation message of the control. It is empty when the control is valid.
get validationMessage(): string Defined in src/internals/mixins/forms/types.ts:61
Returns string
validity
Section titled "validity"Inherited from: IgcInputBaseComponent
The validity state of the control.
get validity(): ValidityState Defined in src/internals/mixins/forms/types.ts:55
Returns ValidityState
value
Section titled "value"The value of the control.
get value(): string Defined in src/components/input/input.ts:133
Returns string
The value of the control.
set value(value: string): void Defined in src/components/input/input.ts:129
Parameters
- value:
string
Returns void
willValidate
Section titled "willValidate"Inherited from: IgcInputBaseComponent
Whether the control is a candidate for constraint validation.
get willValidate(): boolean Defined in src/internals/mixins/forms/types.ts:64
Returns boolean
Methods
Section titled "Methods"Inherited from: IgcInputBaseComponent
Removes focus from the control.
blur(): void Defined in src/components/input/input-base.ts:107
Returns void
checkValidity
Section titled "checkValidity"Inherited from: IgcInputBaseComponent
Checks validity and emits invalid when the control is invalid. Returns
true when the control is valid.
checkValidity(): boolean Defined in src/internals/mixins/forms/types.ts:134
Returns boolean
focus
Section titled "focus"Inherited from: IgcInputBaseComponent
Sets focus on the control.
focus(options: FocusOptions): void Defined in src/components/input/input-base.ts:100
Parameters
- options:
FocusOptions
Returns void
reportValidity
Section titled "reportValidity"Inherited from: IgcInputBaseComponent
Checks validity. As for a native control, an invalid control emits
invalid and takes the focus. It shows its own validation messages, not
the message of the browser. Returns true when the control is valid.
reportValidity(): boolean Defined in src/internals/mixins/forms/types.ts:141
Returns boolean
select
Section titled "select"Inherited from: IgcInputBaseComponent
Selects all the text inside the input.
select(): void Defined in src/components/input/input-base.ts:94
Returns void
setCustomValidity
Section titled "setCustomValidity"Inherited from: IgcInputBaseComponent
Sets a custom validation message. The control is invalid while the message is not empty. An empty string removes the custom error.
setCustomValidity(message: string): void Defined in src/internals/mixins/forms/types.ts:147
Parameters
- message:
string
Returns void
setRangeText
Section titled "setRangeText"Replaces the text from start to end in the input. Without start and
end, replaces the selected text.
setRangeText(replacement: string, start: number, end: number, selectMode: RangeTextSelectMode): void Defined in src/components/input/input.ts:256
Parameters
- replacement:
string - start:
number - end:
number - selectMode:
RangeTextSelectMode
Returns void
setSelectionRange
Section titled "setSelectionRange"Sets the text selection range of the control.
setSelectionRange(start: number, end: number, direction: SelectionRangeDirection): void Defined in src/components/input/input.ts:273
Parameters
- start:
number - end:
number - direction:
SelectionRangeDirection
Returns void
stepDown
Section titled "stepDown"Decrements the numeric value of the input by one or more steps.
stepDown(n: number): void Defined in src/components/input/input.ts:288
Parameters
- n:
number
Returns void
stepUp
Section titled "stepUp"Increments the numeric value of the input by one or more steps.
stepUp(n: number): void Defined in src/components/input/input.ts:282
Parameters
- n:
number