Text Field
Self-contained label, input, and help/error text in one form-associated Web Component. Participates in native forms via ElementInternals and emits a composed change event.
Preview
<esa-text-field label="Full name" placeholder="Jane Doe" help-text="As it appears on the permit."></esa-text-field> Types
The type attribute maps straight to the native input type.
<esa-text-field label="Email" type="email" placeholder="you@example.com"></esa-text-field>
<esa-text-field label="Password" type="password"></esa-text-field>
<esa-text-field label="Count" type="number"></esa-text-field> Sizes
<esa-text-field label="Extra small" size="xs" placeholder="Extra small"></esa-text-field>
<esa-text-field label="Small" size="sm" placeholder="Small"></esa-text-field>
<esa-text-field label="Medium" size="md" placeholder="Medium"></esa-text-field>
<esa-text-field label="Large" size="lg" placeholder="Large"></esa-text-field> States
<esa-text-field label="Required" required placeholder="Cannot be empty"></esa-text-field>
<esa-text-field label="With error" error-text="This field is required." required></esa-text-field>
<esa-text-field label="Disabled" disabled value="Read only"></esa-text-field> Form participation
The element is form-associated. Submitting logs the FormData entry for contact.
<form>
<esa-text-field label="Contact" name="contact" placeholder="Type then submit"></esa-text-field>
<button type="submit">Submit</button>
</form> API
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | '' | Visible label rendered above the input. |
type | 'text' | 'email' | 'password' | 'number' | 'tel' | 'url' | 'text' | Native input type. |
value | string | '' | Current value; mirrored to the form on every input. |
placeholder | string | '' | Placeholder shown when empty. |
help-text | string | '' | Helper text shown below the input. |
error-text | string | '' | Error message; replaces help text and turns the field red when present. |
size | 'xs' | 'sm' | 'md' | 'lg' | 'md' | Control size. |
required | boolean | false | Marks the field required and renders an asterisk on the label. |
disabled | boolean | false | Disables interaction. |
Events
| Event | Type | Default | Description |
|---|---|---|---|
change | CustomEvent<{ value: string }> | — | Fired on every input. Composed and bubbling; detail.value is the current string. |
Accessibility
- Renders a native
<input>associated to its<label>viafor/id. - Sets
aria-invalid="true"whileerror-textis present. - The required asterisk carries an
aria-label="required". - Visible focus ring via
--focus-ring-*tokens.