PRACTICAL WEB TIP
Submenu Peek
A compact submenu opens on hover or keyboard focus, keeping related navigation links accessible.
Live Demo
Hover over the element or use Tab to focus.
Source Code
Copy the HTML, CSS or JavaScript you need for your project.
HTML
<nav class="tbx-1030" aria-label="Sample services navigation"><details><summary>Services <span aria-hidden="true">⌄</span></summary></details><div class="tbx-1030__panel"><button type="button">Web design <span aria-hidden="true">↗</span></button><button type="button">Ongoing support <span aria-hidden="true">↗</span></button><button type="button">Selected work <span aria-hidden="true">↗</span></button></div></nav>
CSS
.tbx-1030{position:relative;width:226px;min-height:187px;font:650 13px/1.45 system-ui,sans-serif;color:#234459}
.tbx-1030 details{position:relative}
.tbx-1030 summary{display:flex;justify-content:space-between;align-items:center;width:226px;padding:12px 15px;border:1px solid #bdcedc;border-radius:6px;background:white;cursor:pointer;list-style:none}
.tbx-1030 summary::-webkit-details-marker{display:none}.tbx-1030 summary span{display:inline-block;transition:transform .25s ease}
.tbx-1030__panel{position:absolute;top:48px;left:0;right:0;padding:5px;background:#fff;border:1px solid #d5e0e8;border-radius:6px;box-shadow:0 12px 20px #162d3c1c;opacity:0;visibility:hidden;transform:translateY(-7px);transition:opacity .2s ease,transform .2s ease,visibility .2s}
.tbx-1030 button{display:flex;justify-content:space-between;align-items:center;width:100%;padding:8px 10px;border:0;border-radius:4px;background:white;color:#254258;text-align:left;cursor:pointer}
.tbx-1030 button:is(:hover,:focus-visible){background:#e8f6f4;color:#126c7d}
.tbx-1030:is(:hover,:focus-within) .tbx-1030__panel,.tbx-1030 details[open]+.tbx-1030__panel{opacity:1;visibility:visible;transform:translateY(0)}
.tbx-1030:is(:hover,:focus-within) summary span,.tbx-1030 details[open] summary span{transform:rotate(180deg)}
.tbx-1030 :is(summary,button):focus-visible{outline:2px solid #855fc2;outline-offset:2px}
@media(hover:none){.tbx-1030 details:not([open])+.tbx-1030__panel{opacity:0;visibility:hidden;pointer-events:none}}
@media(prefers-reduced-motion:reduce){.tbx-1030 summary span,.tbx-1030__panel{transition:none}}
How to Use
Insert the HTML and add the CSS to your stylesheet. Adjust colors and sizes and avoid class conflicts.
Use Case
Useful for navigation menus.
Technical Notes
Keep controls usable on touch devices. Test keyboard focus and reduced-motion preferences.
Mobile:Ensure the interactive content remains accessible without hover on touch devices.
Browser:Uses modern CSS. Check behavior in the browsers you support.
Reduced Motion:Check that prefers-reduced-motion is respected.