Skip to content
Alpha

Hololink UI is under active development. Components, APIs and these docs may change without notice.

Holo Text Field

The <holo-text-field> component is a form-associated custom element for single-line text input. It participates in native <form> submission and constraint validation via ElementInternals.

Use it for:

  • Entering a single line of free text: names, emails, URLs, search terms, numbers (type).
  • A field that submits with a form and shows validation errors.

Don’t use it for:

<holo-text-field label="Email address" type="email" placeholder="you@example.com"></holo-text-field>
<holo-text-field label="Email address" value="locked@example.com" disabled></holo-text-field>
<holo-text-field label="Email address" value="not-an-email" invalid error-message="Please enter a valid email address."></holo-text-field>

The component renders a native <input> (with the type you set) and a <label> linked through for, so role, name and keyboard behaviour come from the browser. required, readonly and disabled are applied to the native input. When invalid is set, the input gets aria-invalid="true", and an errorMessage appears in a role="alert" element referenced by aria-describedby. The required marker is aria-hidden. The component is form-associated through ElementInternals, so it takes part in form submission and validation (“This field is required.”).

Key Action
Tab Moves focus to or from the field
Typing and editing keys Native text input behaviour
  • A visible focus ring (border colour and a 2px ring) is shown with :focus-visible.
  • The border uses border-control, so it meets 3:1 against the surface.
  • A placeholder is not a label. Placeholder text uses the text-tertiary token (contrast-tested at 4.5:1), but it disappears once the user types.
  • autocomplete is forwarded to the native input, so you can declare the input’s purpose (WCAG 1.3.5) for fields that collect information about the user, such as name, email or tel.

You provide:

  • A label. Without one the input has no accessible name.
  • A helpful errorMessage that says how to fix the problem, and invalid set at a sensible time (for example on blur or submit).
  • An appropriate type for the data, such as email or tel.
  • An autocomplete value when the field collects information about the user, for example autocomplete="email".

Importing

import '@philbob-sideprojects/hololink-ui/holo-text-field';

Properties

PropertyAttributeTypeDefaultDescription
autocompleteautocompletestring—Forwarded to the inner input's autocomplete attribute so browsers and assistive technology can identify the input's purpose (WCAG 1.3.5), for example email, name, or current-password.
disableddisabledbooleanfalseIf true, the field is disabled and non-interactive.
errorMessageerror-messagestring—Error message shown (and announced) when invalid is true.
invalidinvalidbooleanfalseMarks the field as invalid, applying invalid styling and ARIA attributes.
labellabelstring—The visible label text for the field.
namenamestring—The form field name submitted with the owning form.
placeholderplaceholderstring—Placeholder text shown when the field is empty.
readonlyreadonlybooleanfalseIf true, the field's value cannot be edited but is still submitted/focusable.
requiredrequiredbooleanfalseIf true, the field must have a value for the owning form to submit.
typetype"email" | "number" | "password" | "search" | "tel" | "text" | "url"'text'The native input type to render.
valuevaluestring''The current value of the field.

Events

EventDetailDescription
holoChangestringEmitted when the field is committed (blur/change) with the current value.
holoInputstringEmitted on every keystroke with the current value.

CSS custom properties

PropertyDescription
--holo-text-field-bgBackground color of the input.
--holo-text-field-border-colorBorder color of the input.
--holo-text-field-border-focusBorder color when focused.
--holo-text-field-border-hoverBorder color on hover.
--holo-text-field-colorText color of the input.
--holo-text-field-error-colorText color of the error message.
--holo-text-field-focus-ringFocus ring color.
--holo-text-field-invalid-borderBorder and focus ring color when invalid is true.
--holo-text-field-label-colorText color of the label.
--holo-text-field-label-gapSpace between the label and the input.
--holo-text-field-radiusCorner radius of the input.
--holo-text-field-required-colorColor of the required indicator.