Menu
CoddyTech

Unavailable Action States

Part of the Responsive UI Patterns section of Coddy's Tailwind CSS journey. Lesson 49 of 55.

An unavailable action needs real behavior as well as appearance. Keep the native disabled attribute on a disabled button. Styling such as disabled:opacity-50 and disabled:cursor-not-allowed can explain the state visually but cannot replace the attribute.

<button disabled class="opacity-100 disabled:opacity-50 cursor-pointer disabled:cursor-not-allowed enabled:hover:underline">Join session</button>

The example limits an underline hover cue to enabled controls with enabled:hover:underline. Stacked variants require both conditions. Without the enabled condition, a disabled button may still acquire the same hover presentation as an available action.

Supplied application behavior owns availability changes. Provide explicit enabled base styles, disabled overrides and a complete return path. Test disabled, enabled, hovered and disabled-again states so cues do not become stale.

challenge icon

Challenge

Medium

Keep Reserve natively disabled initially. Use white as its base background, 50% opacity and a not-allowed cursor while disabled. When the supplied availability toggle enables it, restore full opacity and a pointer cursor; only an enabled hovered button gets #dbeafe. Toggling back must restore disabled cues.

Preserve the supplied content, semantic elements and IDs. Edit the requested utility classes. Press Run preview after edits, then Check/Run code to grade the result. Supplied JavaScript is read-only.

Try it yourself

<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Interface workshop</title><link rel="stylesheet" href="./styles.css"></head><body>
<button id="toggle" class="m-4">Change availability</button><div class="p-4"><button id="reserve" disabled class="p-3 bg-white opacity-100 cursor-pointer">Reserve</button></div>
<script src="./controls.js"></script>
</body></html>
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Responsive UI Patterns