Menu
CoddyTech

Native Menu Disclosures

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

A compact set of secondary links can live inside a native details disclosure. Its first summary is the interactive label. The browser toggles the open attribute and exposes the control state without custom JavaScript.

<details class="p-1 open:p-3"><summary>Library hours</summary><p>Open until six.</p></details>

The example increases padding from 4px to 12px only while open. Tailwind open: follows the native state; it does not implement the toggle. Place it on the details element when styling that element.

Keep the disclosure label descriptive and preserve the native control. Border or padding changes can emphasize expanded content, but they should complement the semantic state rather than replace it.

challenge icon

Challenge

Medium

Style the native travel disclosure with a 1px border on all sides while closed and a 4px border on all sides while open. Preserve its summary control and travel link. Opening and closing must restore the appropriate border.

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>
<details id="menu" class="border-solid border"><summary id="toggle">Travel links</summary><nav aria-label="Travel"><a href="#bus">Bus timetable</a></nav></details>
</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