Active and Disabled States
You'll learn how to provide instant visual feedback when users interact with buttons and form elements using Tailwind's active:, disabled:, and enabled: state variants.
Why These States Matter
When users click a button or interact with a form element, they need immediate visual confirmation that their action registered. Similarly, disabled elements should look obviously non-interactive. These states bridge the gap between static design and responsive user experience.
Think of it like physical buttons: when you press an elevator button, it lights up or depresses slightly. That instant feedback tells you "yes, I received your input." The same principle applies to web interfaces.
The State Variants
active: applies styles when an element is being actively pressed or clicked (the moment between mousedown and mouseup):
<button class="bg-blue-500 active:bg-blue-700">
Press Me
</button>
disabled: styles elements that have the disabled attribute and cannot be interacted with:
<button disabled class="disabled:opacity-50 disabled:cursor-not-allowed">
Unavailable
</button>
enabled: targets elements that are not disabled (useful for creating distinct enabled-state styling):
<input class="enabled:border-blue-500 enabled:hover:border-blue-700" />
Combining States
You can stack these with other variants you've learned:
<button class="bg-green-500 hover:bg-green-600 active:bg-green-700 disabled:opacity-50 disabled:cursor-not-allowed">
Submit
</button>
Key Takeaway: Use active: for press feedback, disabled: to visually indicate non-interactive elements, and enabled: for styling that only applies to interactive elements—creating clear, responsive interfaces that guide users through every interaction state.