Focus-Aware Help Panels
Part of the Responsive UI Patterns section of Coddy's Tailwind CSS journey. Lesson 38 of 55.
A field may need contextual help without displaying every explanation at once. Mark its shared wrapper group and use group-focus-within: on the help panel. The panel can then respond when another descendant, such as the input, receives focus.
<div class="group"><label for="code">Code</label><input id="code"><p class="hidden group-focus-within:block">Use the code on your ticket.</p></div>The example keeps help hidden until the group contains focus. If the help contains a link, keeping that link in the same group lets the panel remain visible while the user tabs into it. A hover-only trigger would miss this keyboard path.
Keep essential instructions available elsewhere or visible when needed; this pattern is for supplemental help. Test focus entering, moving inside and leaving the group, including multiple independent groups on the same page.
Challenge
MediumHide the booking help panel at rest. Show it as a block while focus is anywhere in its supplied group, including the input and the help link. Hide it again after focus moves to Continue. Preserve the label and help link.
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="before">Start</button><div class="group p-4"><label for="field">Booking reference</label><input id="field" class="border"><p id="help" class="hidden">Find the reference in your receipt. <a id="helpLink" href="#example">View example</a></p></div><button id="after">Continue</button><p id="example">AB12</p>
</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 Layouts2Navigation 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