Input
<esp-input>
Wraps a standard HTML input field, providing value binding, input validation, and programmatic focus for Espalier forms and UIs. It supports several input types, and has a slot for an icon.
Input can have color variants. Here are some examples:
Email validation
Set input-type="email" to get built-in email validation. You
can customize the error message with validation-message:
Number input with min/max
Telephone with locale-aware formatting
The tel type uses phone localities to parse and format phone
numbers on blur. The value is submitted as E.164 (e.g.
"+15551234567"). Use tel-localities to specify which regions
are accepted (space-separated region codes); when omitted, a
sensible default set of 10 common regions is used.
Date input with locale-aware mask
The date type displays a placeholder based on the user's
locale (e.g. "MM/DD/YYYY"). The user types freely and the
input parses the date on blur, submitting the value as
ISO 8601 (2025-01-15).
Slots
<esp-input> has a slot:
Default
Place an SVG icon in the slot to have it appear in the input field.
Attributes
<esp-input> has the following attributes:
field-name
field-name has a default value of "".
A string value used for the id of the input field.
input-type
input-type has a default value of "text".
Specifies the type of input, such as text, email, password, etc.
The date type provides a locale-aware placeholder mask —
the user types a date freely, and the value is parsed and
submitted as ISO 8601 on blur. The tel type provides
phone locality matching — the user types digits and
separators, and the value is parsed and submitted as E.164
on blur.
force-lowercase
force-lowercase has a default value of false.
A boolean value. When true, values the user enters are forced to lowercase.
value
value has a default value of "".
The value of the input. For input-type="date", this is
an ISO 8601 date string (e.g. "2025-06-15"). For
input-type="tel", this is an E.164 phone number
(e.g. "+15551234567").
name
name has a default value of "".
The name used when the input participates in a <form>.
required
required has a default value of false.
When true, the field must have a value before the form can be submitted.
required-message
required-message has a default value of "".
A custom message to display when the field is required but empty.
Defaults to "Please fill out this field." when not set.
validation-message
validation-message has a default value of "".
A custom message to display when the value doesn't match
the expected type or pattern. The default depends on the
input type (e.g. "Please enter a valid email address."
for input-type="email").
disabled
disabled has a default value of false.
When true, the input is disabled and cannot be interacted with.
pattern
pattern has a default value of undefined.
A regular expression the value must match. Only applies to text-like types (text, email, url, tel, password, search).
minlength
minlength has a default value of undefined.
Minimum number of characters. Only applies to text-like types.
maxlength
maxlength has a default value of undefined.
Maximum number of characters. Only applies to text-like types.
min
min has a default value of undefined.
Minimum value. For input-type="number" this is passed to
the native input. For input-type="date" it is an ISO 8601
date used for custom range validation.
max
max has a default value of undefined.
Maximum value. For input-type="number" this is passed to
the native input. For input-type="date" it is an ISO 8601
date used for custom range validation.
step
step has a default value of undefined.
Step value for input-type="number".
inputmode
inputmode has a default value of undefined.
Hint the browser about which virtual keyboard to show.
When not set, a sensible default is chosen based on
input-type (e.g. "email" for email, "numeric" for
number and date).
tel-localities
tel-localities has a default value of undefined.
Space-separated list of region codes that defines which
phone localities are accepted for input-type="tel". The
first locality whose format matches wins. When omitted,
defaults to a set of 10 common regions.
Methods
<esp-input> has the following methods:
focus
Focus the input element.
validate
Re-run constraint validation and dispatch validity-changed.
checkValidity
Check whether the current state is valid (delegates to ElementInternals).
traverseToClosest
Traverse up the DOM tree to find the closest element that matches the selector. This method is aware of shadow DOM boundaries and will traverse through them to find the element.
Events
<esp-input> emits the following events:
value-changed
value-changed is of type CustomEvent<string>.
Emitted when the input value changes.
icon-clicked
icon-clicked is of type CustomEvent.
Emitted when the slotted icon is clicked.
CSS Properties
<esp-input> has the following CSS properties:
--esp-field-background
Background color of the shared field shell. Defaults to var(--esp-color-layer-2).
--esp-field-border-color
Border color of the shared field shell. Defaults to var(--esp-color-border).
--esp-field-border-width
Border width of the shared field shell. Defaults to 1px.
--esp-field-text-color
Text color used inside the shared field shell. Defaults to var(--esp-color-text).
--esp-field-hover-bg
Hover background color of the shared field shell. Derived from --esp-field-background.
--esp-field-focus-bg
Focus background color of the shared field shell. Derived from --esp-field-background.
--esp-field-focus-shadow
Shadow color used for shared field focus treatment. Defaults to var(--esp-color-shadow).