Input passes validation.
<label class="vld" style="--accent:#A8E6C1;">
<span class="vld__label">Email address</span>
<span class="vld__row">
<input class="vld__input" type="email" value="name@example.com" required>
<svg class="vld__icon" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="9" fill="none" stroke="currentColor" stroke-width="2"/><path d="m8 12.5 2.5 2.5L16 9" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" fill="none"/></svg>
</span>
<span class="vld__msg">Real <code>:valid</code> pseudo-class — the browser applies it because this value satisfies <code>type="email"</code> natively.</span>
</label>
<style>
.vld { display: block; width: 280px; box-sizing: border-box; font: 14px/1.5 system-ui, sans-serif; color: #241430; background: #FAF7F2; padding: 16px 18px; border-radius: 12px; }
.vld__label { display: block; margin-bottom: 7px; font-size: 12px; font-weight: 600; color: #241430aa; }
.vld__row { position: relative; display: block; }
.vld__input { width: 100%; box-sizing: border-box; font: 14px system-ui, sans-serif; padding: 9px 34px 9px 11px; border-radius: 8px; border: 1.5px solid #24143030; }
.vld__input:valid { border-color: var(--accent); }
.vld__icon { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--accent); display: none; }
.vld__input:valid ~ .vld__icon { display: block; }
.vld__msg { display: block; margin-top: 7px; font-size: 11px; color: #241430888; }
.vld__msg code { background: #24143012; padding: 1px 5px; border-radius: 4px; }
</style><label class="block w-[280px] box-border font-sans text-sm text-[#241430] bg-[#FAF7F2] px-[18px] py-4 rounded-xl">
<span class="block mb-1.5 text-xs font-semibold text-[#241430]/65">Email address</span>
<span class="vld-tw-row relative block">
<input type="email" value="name@example.com" required class="vld-tw-input w-full box-border text-sm pl-2.5 pr-[34px] py-2 rounded-lg border-[1.5px] border-[#24143030]">
<svg class="vld-tw-icon absolute right-2.5 top-1/2 -translate-y-1/2 hidden" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true" style="color:#A8E6C1"><circle cx="12" cy="12" r="9" fill="none" stroke="currentColor" stroke-width="2"/><path d="m8 12.5 2.5 2.5L16 9" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" fill="none"/></svg>
</span>
<span class="block mt-1.5 text-[11px] text-[#241430]/55">Real <code class="bg-[#24143012] px-1.5 py-0.5 rounded">:valid</code> pseudo-class — the browser applies it because this value satisfies <code class="bg-[#24143012] px-1.5 py-0.5 rounded">type="email"</code> natively.</span>
</label>
<style>
.vld-tw-input:valid { border-color: #A8E6C1; }
.vld-tw-input:valid ~ .vld-tw-icon { display: block; }
</style>export function ValidState({
fieldLabel = "Email address",
value = "name@example.com",
accent = "#A8E6C1",
showIcon = true,
}) {
return (
<label style={{ display: "block", width: 280, boxSizing: "border-box", font: "14px/1.5 system-ui, sans-serif", color: "#241430", background: "#FAF7F2", padding: "16px 18px", borderRadius: 12 }}>
<span style={{ display: "block", marginBottom: 7, fontSize: 12, fontWeight: 600, color: "#241430aa" }}>{fieldLabel}</span>
<span style={{ position: "relative", display: "block" }}>
<input type="email" defaultValue={value} required
style={{ width: "100%", boxSizing: "border-box", font: "14px system-ui, sans-serif", padding: "9px 34px 9px 11px", borderRadius: 8, border: `1.5px solid ${accent}` }} />
{showIcon && (
<svg width="16" height="16" viewBox="0 0 24 24" aria-hidden="true" style={{ position: "absolute", right: 10, top: "50%", transform: "translateY(-50%)", color: accent }}>
<circle cx="12" cy="12" r="9" fill="none" stroke="currentColor" strokeWidth="2" /><path d="m8 12.5 2.5 2.5L16 9" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" fill="none" />
</svg>
)}
</span>
<span style={{ display: "block", marginTop: 7, fontSize: 11, color: "#241430888" }}>Real <code>:valid</code> pseudo-class — the browser applies it natively because this value satisfies <code>type="email"</code>.</span>
</label>
);
}