The Input component provides a styled text input with support for validation, labels, and helper text.
Installation
npm install @duskmoon-dev/el-input
Usage
import '@duskmoon-dev/el-input/register' ;
< el-dm-input label = "Email" placeholder = "Enter your email" ></ el-dm-input >
The native input stays mounted while values, labels, helper text, or validation change,
so typing and pasting retain focus and selection. Listen for dm-input while editing
and dm-change when the edit is committed. Registered validators run on blur.
Live Demo
Properties
Property Type Default Description valuestring''Input value labelstring''Label text placeholderstring''Placeholder text type'text' | 'email' | 'password' | 'number' | 'tel' | 'url''text'Input type disabledbooleanfalseDisables the input readonlybooleanfalseMakes input read-only requiredbooleanfalseMarks as required errorstring''Error message to display helperstring''Helper text below input
Basic Examples
With Label
< el-dm-input label = "Username" placeholder = "Enter username" ></ el-dm-input >
With Helper Text
< el-dm-input
label = "Password"
type = "password"
helper = "Must be at least 8 characters"
></ el-dm-input >
With Error
< el-dm-input
label = "Email"
type = "email"
value = "invalid-email"
error = "Please enter a valid email address"
></ el-dm-input >
Text
< el-dm-input type = "text" label = "Name" ></ el-dm-input >
Email
< el-dm-input type = "email" label = "Email" ></ el-dm-input >
Password
< el-dm-input type = "password" label = "Password" ></ el-dm-input >
Number
< el-dm-input type = "number" label = "Quantity" ></ el-dm-input >
States
Disabled
< el-dm-input label = "Disabled" disabled value = "Cannot edit" ></ el-dm-input >
Read-only
< el-dm-input label = "Read-only" readonly value = "View only" ></ el-dm-input >
Required
< el-dm-input label = "Required Field" required ></ el-dm-input >
Events
Event Description inputFired when the value changes changeFired when the value changes and input loses focus focusFired when the input receives focus blurFired when the input loses focus
Event Handling
const input = document. querySelector ( 'el-dm-input' );
input. addEventListener ( 'input' , ( event ) => {
console. log ( 'Value:' , event.target.value);
});
CSS Custom Properties
Property Default Description --input-padding-x0.75remHorizontal padding --input-padding-y0.5remVertical padding --input-border-radius0.375remBorder radius --input-border-colorvar(--color-outline)Border color --input-focus-colorvar(--color-primary)Focus ring color --input-error-colorvar(--color-error)Error state color
Accessibility
Labels are properly associated with inputs
Error messages are announced to screen readers
Focus states are clearly visible
Required fields are indicated with aria-required