Login Form
Authentication form component with validation states and accessibility features.
Basic Login Form
Standard login form with username/email and password fields.
<form class="space-y-6">
<div>
<label for="username" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
Username or Email
</label>
<input type="text"
id="username"
name="username"
class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm placeholder-gray-400 dark:placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white"
placeholder="Enter your username or email">
</div>
<div>
<label for="password" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
Password
</label>
<input type="password"
id="password"
name="password"
class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm placeholder-gray-400 dark:placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white"
placeholder="Enter your password">
</div>
<div class="flex items-center justify-between">
<div class="flex items-center">
<input id="remember-me"
name="remember-me"
type="checkbox"
class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 dark:border-gray-600 rounded dark:bg-gray-700">
<label for="remember-me" class="ml-2 block text-sm text-gray-700 dark:text-gray-300">
Remember me
</label>
</div>
<div class="text-sm">
<a href="#" class="font-medium text-blue-600 hover:text-blue-500 dark:text-blue-400 dark:hover:text-blue-300">
Forgot password?
</a>
</div>
</div>
<div>
<button type="submit"
class="w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 dark:focus:ring-offset-gray-800">
Sign in
</button>
</div>
</form>
Validation States
Login form showing different validation states including errors, success, and loading.
Error State
Loading State
Accessibility Features
✓ WCAG 2.1 AA Compliant
- • Proper semantic HTML with form labels
- • ARIA attributes for validation states
- • High contrast colors for text and borders
- • Keyboard navigation support
- • Screen reader compatible error messages
- • Focus indicators for all interactive elements
Usage Guidelines
When to use
- • User authentication pages
- • Member login areas
- • Admin panel access
- • Protected resource access
Best practices
- • Always include clear validation messages
- • Provide "Forgot password?" functionality
- • Use appropriate input types (email, password)
- • Include loading states for async operations
- • Test with screen readers and keyboard navigation