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
MediumKeep 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>
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Responsive UI Patterns
1Page Shells
Growing Page ShellsFlexible Content RailsBounded Scroll RegionsFull-Bleed RegionsRecap: Page Shells4Form Layouts
Responsive Field GroupsFocused Field GroupsSelectable Form OptionsNative Validation CuesRecap: Form Layouts7Intrinsic Layouts
Auto-Fitting CollectionsResilient Label RowsMulti-Line PreviewsReadable Long TokensRecap: Intrinsic Layouts10Accessible Details
Direction-Aware SpacingComfortable Control TargetsVisible Keyboard FocusUnavailable Action StatesRecap: Accessible Details2Navigation Patterns
Wrapping NavigationCurrent Page CuesNative Menu DisclosuresKeyboard Skip LinksRecap: Navigation5Data Tables
Scrollable Data TablesPredictable Table ColumnsRow State PresentationSticky Table HeadersRecap: Data Tables8Interactive Panels
Expanded Control CuesChoice Card StatesFocus-Aware Help PanelsContent-Aware Empty StatesRecap: Interactive Panels11Project: Event Portal
Portal ShellSession Browser