Component

Validation States Input

Input fields with validation feedback states for error, success, warning, and info

  • Component
  • Tailwind
  • MIT

Preview

Live component

Interactive preview
Open preview
9:41 100%
devsnips.site/library/tailwind/components/input/validation-states/
fluid · no fixed width 100%
No dependencies Production-ready

Install

Add to your project

terminal
npx devsnips add Tailwind/Components/Input/validation-states
registry path: Tailwind/Components/Input/validation-states

Source

Implementation

code.html
<!-- Validation - Error -->
<div>
  <label class="block text-sm font-medium text-gray-700 mb-1">Email</label>
  <input type="email" value="invalid-email" class="w-full px-4 py-3 bg-red-50 border border-red-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-red-500 focus:border-red-500 transition-colors" />
  <p class="mt-1.5 text-sm text-red-600 flex items-center gap-1">
    <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
      <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
    </svg>
    Please enter a valid email address
  </p>
</div>

<!-- Validation - Success -->
<div class="mt-6">
  <label class="block text-sm font-medium text-gray-700 mb-1">Username</label>
  <div class="relative">
    <input type="text" value="johndoe" class="w-full px-4 py-3 pr-12 bg-green-50 border border-green-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-green-500 focus:border-green-500 transition-colors" />
    <div class="absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none">
      <svg class="w-5 h-5 text-green-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />
      </svg>
    </div>
  </div>
  <p class="mt-1.5 text-sm text-green-600 flex items-center gap-1">
    <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
      <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
    </svg>
    Username is available
  </p>
</div>

<!-- Validation - Warning -->
<div class="mt-6">
  <label class="block text-sm font-medium text-gray-700 mb-1">Password Strength</label>
  <input type="password" value="password123" class="w-full px-4 py-3 bg-amber-50 border border-amber-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-amber-500 focus:border-amber-500 transition-colors" />
  <div class="mt-2 flex gap-1">
    <div class="h-1.5 flex-1 rounded-full bg-red-400"></div>
    <div class="h-1.5 flex-1 rounded-full bg-amber-400"></div>
    <div class="h-1.5 flex-1 rounded-full bg-gray-200"></div>
    <div class="h-1.5 flex-1 rounded-full bg-gray-200"></div>
  </div>
  <p class="mt-1.5 text-sm text-amber-600 flex items-center gap-1">
    <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
      <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" />
    </svg>
    Weak password. Add numbers and symbols.
  </p>
</div>

<!-- Validation - Info -->
<div class="mt-6">
  <label class="block text-sm font-medium text-gray-700 mb-1">Referral Code</label>
  <input type="text" placeholder="Enter referral code" class="w-full px-4 py-3 bg-blue-50 border border-blue-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition-colors" />
  <p class="mt-1.5 text-sm text-blue-600 flex items-center gap-1">
    <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
      <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
    </svg>
    Get 20% off with code FRIEND2024
  </p>
</div>
60 lines UTF-8 · LF · Spaces: 2
DevSnips AI ready Claude · Cursor · Windsurf

Agent skill & Model Context Protocol

Pass this component straight into your AI workflow. DevSnips exposes each resource as a structured, addressable registry entry, so your agent installs the real files instead of approximating them.

devsnips://components/input/validation-states
Prompt instruction
I want to use this DevSnips resource in production:

Page:
https://devsnips.site/library/tailwind/components/input/validation-states/

Install: npx devsnips add
Tailwind/Components/Input/validation-states

This is the Validation States Input — Input fields with validation feedback states for error, success, warning, and info

Use this DevSnips resource as the starting point for my project.
Adapt it to my project's stack and conventions, fix any issues,
and make it production-ready while preserving its intended design
and behavior.

Paste into ChatGPT, Claude or your agent — it already carries the page URL and the exact install path.

Resource URI
devsnips://components/input/validation-states