Email Field
Let users enter email addresses with built-in validation and optimized keyboard settings.
Anchor to propertiesProperties
- Anchor to autocompleteautocomplete"on" | "off" | EmailAutocompleteField | `section-${string} email` | `section-${string} home email` | `section-${string} mobile email` | `section-${string} fax email` | `section-${string} pager email` | "shipping email" | "shipping home email" | "shipping mobile email" | "shipping fax email" | "shipping pager email" | "billing email" | "billing home email" | "billing mobile email" | "billing fax email" | "billing pager email" | `section-${string} shipping email` | `section-${string} shipping home email` | `section-${string} shipping mobile email` | `section-${string} shipping fax email` | `section-${string} shipping pager email` | `section-${string} billing email` | `section-${string} billing home email` | `section-${string} billing mobile email` | `section-${string} billing fax email` | `section-${string} billing pager email`
A hint as to the intended content of the field.
When set to
on
(the default), this property indicates that the field should support autofill, but you do not have any more semantic information on the intended contents.When set to
off
, you are indicating that this field contains sensitive information, or contents that are never saved, like one-time codes.Alternatively, you can provide value which describes the specific data you would like to be entered into this field during autofill.
- Anchor to defaultValuedefaultValuestring
The default value for the field.
- Anchor to detailsdetailsstring
Additional text to provide context or guidance for the field. This text is displayed along with the field and its label to offer more information or instructions to the user.
This will also be exposed to screen reader users.
- Anchor to disableddisabledboolean
Disables the field, disallowing any interaction.
- Anchor to errorerrorstring
Indicate an error to the user. The field will be given a specific stylistic treatment to communicate problems that have to be resolved immediately.
- string
A unique identifier for the element.
- Anchor to labellabelstring
Content to use as the field label.
- Anchor to labelAccessibilityVisibilitylabelAccessibilityVisibility"visible" | "exclusive"
Changes the visibility of the component's label.
visible
: the label is visible to all users.exclusive
: the label is visually hidden but remains in the accessibility tree.
- Anchor to maxLengthmaxLengthnumber
Specifies the maximum number of characters allowed.
- Anchor to minLengthminLengthnumber
Specifies the min number of characters allowed.
- Anchor to namenamestring
An identifier for the field that is unique within the nearest containing form.
- Anchor to placeholderplaceholderstring
A short hint that describes the expected value of the field.
- Anchor to readOnlyreadOnlyboolean
The field cannot be edited by the user. It is focusable will be announced by screen readers.
- Anchor to requiredrequiredboolean
Whether the field needs a value. This requirement adds semantic value to the field, but it will not cause an error to appear automatically. If you want to present an error when this field is empty, you can do so with the
error
property.- Anchor to valuevaluestring
The current value for the field. If omitted, the field will be empty.
EmailField
- __@internals$4@5319
ElementInternals
- adoptedCallback
() => void
- attributeChangedCallback
(name: string) => void
- autocomplete
A hint as to the intended content of the field. When set to `on` (the default), this property indicates that the field should support autofill, but you do not have any more semantic information on the intended contents. When set to `off`, you are indicating that this field contains sensitive information, or contents that are never saved, like one-time codes. Alternatively, you can provide value which describes the specific data you would like to be entered into this field during autofill.
"on" | "off" | EmailAutocompleteField | `section-${string} email` | `section-${string} home email` | `section-${string} mobile email` | `section-${string} fax email` | `section-${string} pager email` | "shipping email" | "shipping home email" | "shipping mobile email" | "shipping fax email" | "shipping pager email" | "billing email" | "billing home email" | "billing mobile email" | "billing fax email" | "billing pager email" | `section-${string} shipping email` | `section-${string} shipping home email` | `section-${string} shipping mobile email` | `section-${string} shipping fax email` | `section-${string} shipping pager email` | `section-${string} billing email` | `section-${string} billing home email` | `section-${string} billing mobile email` | `section-${string} billing fax email` | `section-${string} billing pager email`
- click
Like the standard `element.click()`, but you can influence the behavior with a `sourceEvent`. For example, if the `sourceEvent` was a middle click, or has particular keys held down, components will attempt to produce the desired behavior on links, such as opening the page in the background tab.
({ sourceEvent }?: ClickOptions) => void
- connectedCallback
() => void
- defaultValue
The default value for the field.
string
- details
Additional text to provide context or guidance for the field. This text is displayed along with the field and its label to offer more information or instructions to the user. This will also be exposed to screen reader users.
string
- disabled
Disables the field, disallowing any interaction.
boolean
- disconnectedCallback
() => void
- error
Indicate an error to the user. The field will be given a specific stylistic treatment to communicate problems that have to be resolved immediately.
string
- formResetCallback
() => void
- getAttribute
Global keyboard event handlers for things like key bindings typically ignore keystrokes originating from within input elements. Unfortunately, these never account for a Custom Element being the input element. To fix this, we spoof getAttribute & hasAttribute to make a PreactFieldElement appear as a contentEditable "input" when it contains a focused input element.
(qualifiedName: string) => string
- hasAttribute
(qualifiedName: string) => boolean
- id
A unique identifier for the element.
string
- isContentEditable
Checks if the shadow tree contains a focused input (input, textarea, select, <x contentEditable>). Note: this does _not_ return true for focussed non-field form elements like buttons.
boolean
- label
Content to use as the field label.
string
- labelAccessibilityVisibility
Changes the visibility of the component's label. - `visible`: the label is visible to all users. - `exclusive`: the label is visually hidden but remains in the accessibility tree.
"visible" | "exclusive"
- maxLength
Specifies the maximum number of characters allowed.
number
- minLength
Specifies the min number of characters allowed.
number
- name
An identifier for the field that is unique within the nearest containing form.
string
- placeholder
A short hint that describes the expected value of the field.
string
- queueRender
Queue a run of the render function. You shouldn't need to call this manually - it should be handled by changes to @property values.
() => void
- readOnly
The field cannot be edited by the user. It is focusable will be announced by screen readers.
boolean
- required
Whether the field needs a value. This requirement adds semantic value to the field, but it will not cause an error to appear automatically. If you want to present an error when this field is empty, you can do so with the `error` property.
boolean
- setAttribute
(name: string, value: string) => void
- value
The current value for the field. If omitted, the field will be empty.
string
declare class EmailField
extends PreactFieldElement<EmailFieldProps['autocomplete']>
implements EmailFieldProps
{
accessor autocomplete: EmailFieldProps['autocomplete'];
accessor maxLength: EmailFieldProps['maxLength'];
accessor minLength: EmailFieldProps['minLength'];
constructor();
}
EmailAutocompleteField
'url' | 'language' | 'organization' | 'additional-name' | 'address-level1' | 'address-level2' | 'address-level3' | 'address-level4' | 'address-line1' | 'address-line2' | 'address-line3' | 'country-name' | 'country' | 'current-password' | 'family-name' | 'given-name' | 'honorific-prefix' | 'honorific-suffix' | 'name' | 'new-password' | 'nickname' | 'one-time-code' | 'organization-title' | 'photo' | 'postal-code' | 'sex' | 'street-address' | 'transaction-amount' | 'transaction-currency' | 'username' | 'bday-day' | 'bday-month' | 'bday-year' | 'bday' | 'cc-additional-name' | 'cc-expiry-month' | 'cc-expiry-year' | 'cc-expiry' | 'cc-family-name' | 'cc-given-name' | 'cc-name' | 'cc-number' | 'cc-csc' | 'cc-type' | 'impp' | 'home impp' | 'mobile impp' | 'fax impp' | 'pager impp' | 'tel' | 'tel-area-code' | 'tel-country-code' | 'tel-extension' | 'tel-local-prefix' | 'tel-local-suffix' | 'tel-local' | 'tel-national' | 'home tel' | 'mobile tel' | 'fax tel' | 'pager tel' | 'home tel-area-code' | 'mobile tel-area-code' | 'fax tel-area-code' | 'pager tel-area-code' | 'home tel-country-code' | 'mobile tel-country-code' | 'fax tel-country-code' | 'pager tel-country-code' | 'home tel-extension' | 'mobile tel-extension' | 'fax tel-extension' | 'pager tel-extension' | 'home tel-local-prefix' | 'mobile tel-local-prefix' | 'fax tel-local-prefix' | 'pager tel-local-prefix' | 'home tel-local-suffix' | 'mobile tel-local-suffix' | 'fax tel-local-suffix' | 'pager tel-local-suffix' | 'home tel-local' | 'mobile tel-local' | 'fax tel-local' | 'pager tel-local' | 'home tel-national' | 'mobile tel-national' | 'fax tel-national' | 'pager tel-national'
ClickOptions
- sourceEvent
The event you want to influence the synthetic click.
ActivationEventEsque
export interface ClickOptions {
/**
* The event you want to influence the synthetic click.
*/
sourceEvent?: ActivationEventEsque;
}
ActivationEventEsque
- button
number
- ctrlKey
boolean
- metaKey
boolean
- shiftKey
boolean
export interface ActivationEventEsque {
shiftKey: boolean;
metaKey: boolean;
ctrlKey: boolean;
button: number;
}
Anchor to eventsEvents
Learn more about registering events.
- Anchor to blurblurCallbackEventListener<'input'>
- Anchor to changechangeCallbackEventListener<'input'>
- Anchor to focusfocusCallbackEventListener<'input'>
- Anchor to inputinputCallbackEventListener<'input'>
EmailFieldEvents
- blur
CallbackEventListener<'input'>
- change
CallbackEventListener<'input'>
- focus
CallbackEventListener<'input'>
- input
CallbackEventListener<'input'>
export interface EmailFieldEvents {
change: CallbackEventListener<'input'>;
input: CallbackEventListener<'input'>;
blur: CallbackEventListener<'input'>;
focus: CallbackEventListener<'input'>;
}
CallbackEventListener
(EventListener & {
(event: CallbackEvent<T>): void;
}) | null
CallbackEvent
Event & {
currentTarget: HTMLElementTagNameMap[T];
}
Code
examples
Code
<s-email-field label="Email" placeholder="bernadette.lapresse@jadedpixel.com" details="Used for sending notifications" ></s-email-field>
<!DOCTYPE html><html><head><style>html, body {height:100%} body {box-sizing: border-box; margin: 0; padding:0.5rem; display: grid; place-items: center; gap: 0.5rem;}</style><script src="https://cdn.shopify.com/shopifycloud/app-bridge-ui-experimental.js"></script></head><body><s-email-field label="Email" placeholder="bernadette.lapresse@jadedpixel.com" details="Used for sending notifications" ></s-email-field> </body></html>