Skip to content

Field Error Alert

A copy-paste toasts & alerts component in pure HTML & CSS. Zero dependencies, framework-agnostic, MIT-licensed.

Toasts & AlertsHTMLCSSany framework

Copy into your project

HTML
<div class="nuda-ta2-field">
  <label class="nuda-ta2-field__label" for="ta2-field-error-email">Email address</label>
  <input id="ta2-field-error-email" class="nuda-ta2-field__input" type="email"
    value="ana@company" aria-invalid="true" aria-describedby="ta2-field-error-msg">
  <p class="nuda-ta2-field__error" id="ta2-field-error-msg" role="alert" aria-live="assertive">
    <span aria-hidden="true">&#9888;</span> Enter a valid email address
  </p>
</div>
CSS
.nuda-ta2-field {
  --r: #ff5e7a;
  display: flex;
  flex-direction: column;
  gap: .4rem;
  min-width: 230px;
  max-width: 280px;
}

.nuda-ta2-field__label {
  color: #cfcfcf;
  font-size: .75rem;
  font-weight: 600;
}

.nuda-ta2-field__input {
  min-height: 44px;
  box-sizing: border-box;
  padding: 0 .75rem;
  border-radius: 8px;
  border: 1.5px solid var(--r);
  background: #161616;
  color: #fafafa;
  font-size: .85rem;
  animation: _nuda-ta2fieldshake .4s ease;
}

.nuda-ta2-field__input:focus-visible {
  outline: 2px solid var(--r);
  outline-offset: 2px;
}

.nuda-ta2-field__error {
  display: flex;
  align-items: center;
  gap: .35rem;
  color: var(--r);
  font-size: .72rem;
  margin: 0;
  animation: _nuda-ta2fielderrin .25s ease-out both;
}

@keyframes _nuda-ta2fieldshake {
  0%,100% {
    transform: translateX(0);
  }
  20%,60% {
    transform: translateX(-3px);
  }
  40%,80% {
    transform: translateX(3px);
  }
}

@keyframes _nuda-ta2fielderrin {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion:reduce) {
  .nuda-ta2-field__input {
    animation: none;
  }
  .nuda-ta2-field__error {
    animation: none;
  }
}

How to use Field Error Alert

Paste the HTML where you need it and the CSS into a global stylesheet (or a <style> tag). Every class is prefixed nuda- so it never collides with Tailwind or your own styles. Tweak the CSS custom properties to match your design system.

Works in React, Vue, Svelte, Astro, Next.js, Nuxt, Laravel Blade, Django, Rails — or a single .html file. No npm install, no build step.

More toasts & alerts components

← Browse all NudaUI components