You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Material Design 3 Text Field web component — framework-agnostic, built with Lit.
An accessible M3 Text Field web component following the Material Design 3 text field specifications. Supports filled and outlined variants with labels, helper text, error states, and leading/trailing icons. Works in Angular, React, Vue, Svelte, or plain HTML — no build step required.
Features
Filled and outlined variants
Floating label animation
Error and helper text states
Leading and trailing icon slots
Character counter support
Keyboard accessible with proper ARIA attributes
Framework-agnostic custom element
Installation
npm install @banegasn/m3-text-field
# or
pnpm add @banegasn/m3-text-field
# or
yarn add @banegasn/m3-text-field
CDN Usage (no build step)
<!DOCTYPE html><htmllang="en"><head><metacharset="UTF-8" /><title>M3 Text Field Demo</title><scripttype="module" src="https://cdn.jsdelivr.net/npm/@banegasn/m3-text-field/+esm"></script><style>body { font-family: Roboto, sans-serif; padding:32px; background:#fef7ff; }
.demo { display: flex; flex-direction: column; gap:24px; max-width:360px; }
</style></head><body><divclass="demo"><!-- Filled (default) --><m3-text-fieldlabel="Username" placeholder="Enter username"></m3-text-field><!-- Outlined --><m3-text-fieldvariant="outlined" label="Email" type="email" placeholder="you@example.com"></m3-text-field><!-- With helper text --><m3-text-fieldlabel="Password" type="password" helper-text="At least 8 characters"></m3-text-field><!-- Error state --><m3-text-fieldlabel="Phone" errorerror-text="Invalid phone number" value="abc"></m3-text-field><!-- Disabled --><m3-text-fieldlabel="Read only" value="Cannot edit" disabled></m3-text-field></div><script>document.querySelectorAll('m3-text-field').forEach(field=>{field.addEventListener('text-field-input',(e)=>{console.log('Input:',e.detail.value);});});</script></body></html>
npm Usage
import'@banegasn/m3-text-field';
<m3-text-fieldlabel="Name" placeholder="Enter your name"></m3-text-field><m3-text-fieldvariant="outlined" label="Email" type="email"></m3-text-field><m3-text-fieldlabel="Password" type="password" helper-text="Min 8 characters"></m3-text-field>