EccUtilsDesignInput Component
Overview
The ecc-utils-design-input component is a versatile, styled text field for form data entry. It supports various input types, placeholder text, and disabled states.
This component is a wrapper around the native HTML <input> element, providing consistent styling and custom events.
Usage
Basic Input
This example shows a default text input field.
Input with Label
This example shows an input field associated with a label.
Properties
| Property | Type | Default | Description |
|---|---|---|---|
type | string | "text" | The type of input (e.g., text, email). |
placeholder | string | "" | Placeholder text for the input. |
value | string | "" | The current value of the input. |
disabled | boolean | false | When true, disables the input. |
invalid | boolean | false | When true, marks the input as invalid (also implied by error). |
error | string | "" | Error message shown under the input, e.g. from an API. |
type
Specifies the input type, determining the data format and keyboard layout on mobile devices.
<EccUtilsDesignInput type="password" />placeholder
Provides a hint to the user about what information to enter in the input field.
<EccUtilsDesignInput placeholder="Your email address" />value
The current value of the input field. Can be used for controlled components in React.
<EccUtilsDesignInput value="pre-filled.value@example.com" />disabled
When true, the input is non-interactive and visually de-emphasized.
<EccUtilsDesignInput disabled={true} />invalid and error
error shows a message under the input, e.g. one that an API returned for this field (see Field errors), and marks the input as invalid: it gets a red border, aria-invalid="true" and aria-describedby pointing to the message, and screen readers announce the message (aria-live="polite"). invalid marks the input as invalid without a message, e.g. when the message is shown elsewhere. Clear both when the user changes the value or submits again. The message has the part error for styling (ecc-utils-design-input::part(error)).
<EccUtilsDesignInput error="Must be a valid URI." />Attribute Forwarding
Set these attributes on <ecc-utils-design-input> to forward them to the native <input> inside its shadow root:
- Native attributes:
name,required,readonly,autocomplete,minlength,maxlength,min,max,step, andpattern. - ARIA attributes such as
aria-label,aria-description,aria-invalid, andaria-required. Host values override component defaults, exceptaria-describedbyis combined with the built-in error reference andaria-invalidis true if the host saystrueor the component is invalid. Thusaria-invalid="false"cannot suppress an activeinvalidstate or non-emptyerror. Removing a host override restores the current component default, if one exists. Thelabelproperty supplies the defaultaria-label.
Forwarded attributes are synchronized after rendering and when host attributes change. Removing a forwarded native attribute removes it from the inner control. Properties such as type, placeholder, value, and disabled are handled separately by the component. Host attributes such as id, class, style, and slot are not copied to the inner control.
ARIA References
The controller resolves aria-activedescendant, aria-controls, aria-describedby, aria-details, aria-errormessage, aria-flowto, aria-labelledby, and aria-owns against IDs in the host's document or containing shadow root. For aria-describedby, consumer references are added to the component's built-in error reference, so both descriptions are announced. Where supported, native element-reference properties connect the inner control to those elements. References are updated when matching elements are inserted, removed, replaced, or change ID.
If the browser lacks the corresponding property, aria-labelledby, aria-describedby, and aria-errormessage use hidden shadow-local copies of the referenced accessible text, including sources such as aria-label and image alt. Other unsupported reference attributes are omitted from the inner control rather than forwarding IDs that cannot resolve across the shadow boundary.
<span id="account-label">Account name</span>
<ecc-utils-design-input
aria-labelledby="account-label"
aria-describedby="account-hint"
required
minlength="2"
></ecc-utils-design-input>
<p id="account-hint">Use at least two characters.</p>Forwarding does not establish a native label's for association across shadow roots. Use label, aria-label, or aria-labelledby to provide an accessible name. Forwarding name also does not make the custom element form-associated: collect its value explicitly when submitting an outer form. Forwarded constraints apply to the inner input, not automatically to the outer form's validation.
Events
| Event Name | React Event Name | Detail Type | Description |
|---|---|---|---|
ecc-input-changed | onEccInputChanged | { value: string } | Fired when the value of the input changes. |
ecc-input-changed
Fires whenever the user types or pastes content into the input.
<EccUtilsDesignInput
onEccInputChanged={(event) => {
console.log(event.detail.value);
}}
/>