Free ToolsGuidesCase StudiesResourcesAboutContact
Get Your Free AI Automation Audit Book a Free 30-Minute Strategy Call
Playground~/frontend Open editor

~/css/navigation

42 CSS Navigation

22 Pure CSS20 with JSPublished 2026-10-03Free · no sign-up

Every navigation pattern on one page: responsive, sticky and glass navbars, hamburger buttons and mobile menus, tabs that work without JavaScript, accordions, breadcrumbs, pagination and an app sidebar. Navigation components built to be found and used by everyone: a responsive navbar with a proper menu button, tabs that work without JavaScript, an FAQ accordion on native details, breadcrumbs, pagination and an app sidebar. Each one handles keyboard focus and tells screen readers where the visitor is.

01. Responsive Navbar with Menu Button

CSS + JS

A header with a logo, links and a call-to-action that turns into a menu button on small screens. The button is a real button with aria-expanded and aria-controls, so screen readers announce whether the menu is open, and Escape closes it. Resize the editor preview below 600px to see the mobile menu.

View code
<header class="ttn-bar">
  <a href="#" class="ttn-logo">Northwind</a>
  <button class="ttn-toggle" aria-expanded="false" aria-controls="ttn-menu">Menu</button>
  <nav id="ttn-menu" class="ttn-menu" aria-label="Main">
    <a href="#" aria-current="page">Shop</a>
    <a href="#">Collections</a>
    <a href="#">About</a>
    <a href="#" class="ttn-cta">Cart (2)</a>
  </nav>
</header>
.ttn-bar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(100%, 760px);
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 14px;
  background: #121722;
  font-family: Inter, system-ui, sans-serif;
}
.ttn-logo { color: #F5F7FA; font-weight: 800; text-decoration: none; }
.ttn-menu { display: flex; align-items: center; gap: 4px; }
.ttn-menu a { padding: 8px 12px; border-radius: 8px; color: #A7AFBD; font-size: 14px; font-weight: 600; text-decoration: none; }
.ttn-menu a:hover, .ttn-menu a[aria-current="page"] { color: #F5F7FA; background: rgba(255, 255, 255, .06); }
.ttn-menu .ttn-cta { margin-left: 8px; background: #5B8CFF; color: #080A0F; }
.ttn-toggle { display: none; padding: 8px 12px; border: 1px solid rgba(255, 255, 255, .2); border-radius: 8px; background: none; color: #F5F7FA; font: 600 14px Inter, system-ui, sans-serif; cursor: pointer; }
a:focus-visible, .ttn-toggle:focus-visible { outline: 2px solid #7DA3FF; outline-offset: 2px; }
@media (max-width: 600px) {
  .ttn-toggle { display: block; }
  .ttn-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    display: none;
    flex-direction: column;
    align-items: stretch;
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 14px;
    background: #121722;
  }
  .ttn-menu.is-open { display: flex; }
  .ttn-menu .ttn-cta { margin-left: 0; text-align: center; }
}
var toggle = document.querySelector('.ttn-toggle');
var menu = document.getElementById('ttn-menu');
function setOpen(open) {
  menu.classList.toggle('is-open', open);
  toggle.setAttribute('aria-expanded', open ? 'true' : 'false');
  toggle.textContent = open ? 'Close' : 'Menu';
}
toggle.addEventListener('click', function () { setOpen(!menu.classList.contains('is-open')); });
document.addEventListener('keydown', function (e) { if (e.key === 'Escape') { setOpen(false); toggle.focus(); } });

02. Tabs (No JavaScript)

Pure CSS

Three tabs switched with hidden radio buttons and the :checked selector, so they work without JavaScript and arrow keys move between them. The active tab gets an underline and stronger text. For complex apps, add the full ARIA tabs pattern with JavaScript; for simple content panels this is enough.

View code
<div class="ttn-tabs">
  <input type="radio" name="ttn-tab" id="ttn-t1" checked>
  <label for="ttn-t1">Details</label>
  <input type="radio" name="ttn-tab" id="ttn-t2">
  <label for="ttn-t2">Shipping</label>
  <input type="radio" name="ttn-tab" id="ttn-t3">
  <label for="ttn-t3">Returns</label>
  <div class="ttn-panel" id="ttn-p1">Solid oak, oiled finish. 40 × 30 × 12 cm.</div>
  <div class="ttn-panel" id="ttn-p2">Ships in 2 working days. Free over $80.</div>
  <div class="ttn-panel" id="ttn-p3">Return within 30 days for a full refund.</div>
</div>
.ttn-tabs {
  display: flex;
  flex-wrap: wrap;
  width: min(100%, 520px);
  font-family: Inter, system-ui, sans-serif;
}
.ttn-tabs input { position: absolute; opacity: 0; pointer-events: none; }
.ttn-tabs label {
  padding: 12px 16px;
  border-bottom: 2px solid rgba(255, 255, 255, .1);
  color: #A7AFBD;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.ttn-tabs input:checked + label { color: #F5F7FA; border-bottom-color: #5B8CFF; }
.ttn-tabs input:focus-visible + label { outline: 2px solid #7DA3FF; outline-offset: -2px; border-radius: 6px 6px 0 0; }
.ttn-panel {
  display: none;
  width: 100%;
  order: 1;
  padding: 18px 4px;
  color: #D7DCE6;
  line-height: 1.6;
}
#ttn-t1:checked ~ #ttn-p1, #ttn-t2:checked ~ #ttn-p2, #ttn-t3:checked ~ #ttn-p3 { display: block; }

03. Accordion with details and summary

Pure CSS

An FAQ accordion built on the native details and summary elements, which are keyboard accessible and announced correctly by screen readers with no JavaScript. The plus sign rotates into a cross when a panel opens. Adding the same name attribute to each details element makes only one open at a time in current browsers.

View code
<div class="ttn-acc">
  <details name="ttn-faq" open>
    <summary>How long does delivery take?</summary>
    <p>Most orders arrive in two to four working days.</p>
  </details>
  <details name="ttn-faq">
    <summary>Can I return an item?</summary>
    <p>Yes, within 30 days, as long as it is unused.</p>
  </details>
  <details name="ttn-faq">
    <summary>Do you ship abroad?</summary>
    <p>We ship to most countries. Costs are shown at checkout.</p>
  </details>
</div>
.ttn-acc { display: grid; gap: 8px; width: min(100%, 520px); font-family: Inter, system-ui, sans-serif; }
.ttn-acc details { border: 1px solid rgba(255, 255, 255, .1); border-radius: 12px; background: #121722; }
.ttn-acc summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  color: #F5F7FA;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}
.ttn-acc summary::-webkit-details-marker { display: none; }
.ttn-acc summary::after { content: "+"; color: #7DA3FF; font-size: 20px; line-height: 1; transition: transform .2s ease; }
.ttn-acc details[open] summary::after { transform: rotate(45deg); }
.ttn-acc summary:focus-visible { outline: 2px solid #7DA3FF; outline-offset: 2px; border-radius: 12px; }
.ttn-acc p { margin: 0; padding: 0 16px 16px; color: #A7AFBD; line-height: 1.6; }
@media (prefers-reduced-motion: reduce) { .ttn-acc summary::after { transition: none; } }

05. Pagination

Pure CSS

Page links with previous and next controls, a current page marker and an ellipsis for skipped pages. Every control is at least 40px square for touch, the current page uses aria-current so it is announced, and disabled controls are real disabled states rather than just greyed-out text.

View code
<nav class="ttn-pages" aria-label="Pagination">
  <a href="#" class="ttn-prev" aria-disabled="true" tabindex="-1">Previous</a>
  <a href="#" aria-current="page">1</a>
  <a href="#">2</a>
  <a href="#">3</a>
  <span aria-hidden="true">…</span>
  <a href="#">12</a>
  <a href="#" class="ttn-next">Next</a>
</nav>
.ttn-pages { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-family: Inter, system-ui, sans-serif; }
.ttn-pages a, .ttn-pages span {
  display: grid;
  place-items: center;
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 10px;
  color: #D7DCE6;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}
.ttn-pages span { border-color: transparent; color: #7F8899; }
.ttn-pages a:hover { background: rgba(255, 255, 255, .06); }
.ttn-pages a[aria-current="page"] { border-color: transparent; background: #5B8CFF; color: #080A0F; }
.ttn-pages a[aria-disabled="true"] { opacity: .4; pointer-events: none; }
.ttn-pages a:focus-visible { outline: 2px solid #7DA3FF; outline-offset: 2px; }

07. Hamburger Toggle Below 480px

ResponsiveHamburger

Links sit in a row on wide containers and collapse behind a Menu button on narrow ones, opening as a vertical list below the bar. The breakpoint is a container query, so the navbar responds to the space it is given, not the window.

View code
<div class="rn1"><nav aria-label="Main"><a class="logo" href="#home">Kite</a><button aria-expanded="false" aria-controls="rn1l" class="mb"><span aria-hidden="true">☰</span> Menu</button><ul id="rn1l"><li><a href="#product">Product</a></li><li><a href="#pricing">Pricing</a></li><li><a href="#docs">Docs</a></li><li><a href="#login">Log in</a></li></ul></nav></div>
.rn1 { width: 600px; max-width: 100%; container-type: inline-size; font: 600 14px Inter, system-ui, sans-serif; }
.rn1 nav { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; padding: 12px 16px; border: 1px solid #e4e7ec; border-radius: 12px; background: #fff; }
.rn1 .logo { margin-right: auto; color: #101828; font-weight: 900; font-size: 18px; text-decoration: none; }
.rn1 ul { display: flex; gap: 18px; margin: 0; padding: 0; list-style: none; }
.rn1 ul a { color: #344054; text-decoration: none; }
.rn1 .mb { display: none; padding: 7px 12px; border: 1px solid #d0d5dd; border-radius: 8px; background: #fff; font: inherit; cursor: pointer; }
.rn1 a:focus-visible, .rn1 button:focus-visible { outline: 3px solid #84adff; outline-offset: 2px; border-radius: 6px; }
@container (max-width: 479px) {
  .rn1 .mb { display: block; }
  .rn1 ul { display: none; flex-basis: 100%; flex-direction: column; gap: 0; }
  .rn1 ul.open { display: flex; } .rn1 ul a { display: block; padding: 10px 0; border-top: 1px solid #f2f4f7; }
}
var b = document.querySelector('.rn1 .mb'), l = document.getElementById('rn1l');
b.onclick = function () { var o = l.classList.toggle('open'); b.setAttribute('aria-expanded', o); };

08. Priority Plus: Overflow into More

ResponsivePriority plus

Links that fit stay visible and the rest move into a More menu, so the most important links never disappear behind a hamburger. A ResizeObserver measures the bar and moves list items between the two lists in source order.

View code
<div class="rn2"><nav aria-label="Sections"><ul class="vis"><li><a href="#news">News</a></li><li><a href="#sport">Sport</a></li><li><a href="#culture">Culture</a></li><li><a href="#science">Science</a></li><li><a href="#travel">Travel</a></li><li><a href="#food">Food</a></li></ul><div class="more" hidden><button aria-expanded="false" aria-controls="rn2m">More</button><ul id="rn2m" hidden></ul></div></nav></div>
.rn2 { width: 560px; max-width: 100%; resize: horizontal; overflow: hidden; min-width: 180px; padding-bottom: 120px; font: 600 14px Inter, system-ui, sans-serif; }
.rn2 nav { position: relative; display: flex; align-items: center; padding: 8px 10px; border-radius: 12px; background: #151b2e; }
.rn2 ul { margin: 0; padding: 0; list-style: none; }
.rn2 .vis { display: flex; flex: 1; min-width: 0; gap: 4px; overflow: hidden; }
.rn2 a { display: block; padding: 7px 10px; border-radius: 8px; color: #cbd5e1; text-decoration: none; white-space: nowrap; } .rn2 a:hover { background: #1e2640; color: #fff; }
.rn2 .more { position: relative; }
.rn2 button { padding: 7px 10px; border: 0; border-radius: 8px; background: #263048; color: #fff; font: inherit; cursor: pointer; }
.rn2 #rn2m { position: absolute; right: 0; top: calc(100% + 6px); min-width: 140px; padding: 6px; border-radius: 10px; background: #1e2640; }
.rn2 :focus-visible { outline: 2px solid #93c5fd; outline-offset: 1px; }
var nav = document.querySelector('.rn2 nav'), vis = nav.querySelector('.vis'), more = nav.querySelector('.more'), mb = more.querySelector('button'), list = document.getElementById('rn2m');
function fit() {
  while (list.firstElementChild) vis.appendChild(list.firstElementChild);
  more.hidden = true;
  if (vis.scrollWidth <= vis.clientWidth) return;
  more.hidden = false;
  while (vis.scrollWidth > vis.clientWidth && vis.lastElementChild) list.insertBefore(vis.lastElementChild, list.firstChild);
}
mb.onclick = function () { var o = mb.getAttribute('aria-expanded') !== 'true'; mb.setAttribute('aria-expanded', o); list.hidden = !o; };
new ResizeObserver(fit).observe(nav);

09. Scrollable Link Row with Fades

ResponsiveScroll

On narrow screens the links stay in one row that scrolls sideways, with faded edges hinting that there is more, the pattern news and shop sites use for categories. The fade is a mask on the list, and the row is a labelled navigation landmark.

View code
<nav class="rn3" aria-label="Categories"><ul><li><a href="#all" aria-current="page">All</a></li><li><a href="#dresses">Dresses</a></li><li><a href="#knitwear">Knitwear</a></li><li><a href="#trousers">Trousers</a></li><li><a href="#shoes">Shoes</a></li><li><a href="#bags">Bags</a></li><li><a href="#jewellery">Jewellery</a></li></ul></nav>
.rn3 { width: 320px; max-width: 100%; font: 600 14px Inter, system-ui, sans-serif; }
.rn3 ul { display: flex; gap: 6px; margin: 0; padding: 4px 16px; list-style: none; overflow-x: auto; scrollbar-width: none; -webkit-mask: linear-gradient(90deg, transparent, #000 16px, #000 calc(100% - 24px), transparent); mask: linear-gradient(90deg, transparent, #000 16px, #000 calc(100% - 24px), transparent); }
.rn3 ul::-webkit-scrollbar { display: none; }
.rn3 a { display: block; padding: 8px 14px; border: 1px solid #d0d5dd; border-radius: 999px; color: #344054; text-decoration: none; white-space: nowrap; }
.rn3 a[aria-current] { background: #101828; border-color: #101828; color: #fff; }
.rn3 a:focus-visible { outline: 3px solid #84adff; outline-offset: 1px; }

10. Full-Screen Overlay Menu

ResponsiveOverlay

The menu button opens a full-screen overlay with large links, built on a modal dialog so focus is trapped inside it, the page behind is inert and Escape closes it. The overlay fades in with @starting-style.

View code
<div class="rn4"><header><a class="logo" href="#home">Field</a><button class="open" aria-haspopup="dialog">Menu</button></header><dialog aria-label="Menu"><button class="close" aria-label="Close menu">&times;</button><nav aria-label="Main"><a href="#work">Work</a><a href="#studio">Studio</a><a href="#journal">Journal</a><a href="#contact">Contact</a></nav></dialog></div>
.rn4 { width: 400px; max-width: 100%; font-family: Inter, system-ui, sans-serif; }
.rn4 header { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-radius: 12px; background: #151b2e; }
.rn4 .logo { color: #fff; font-weight: 900; font-size: 18px; text-decoration: none; }
.rn4 .open { padding: 7px 12px; border: 1px solid #3a4670; border-radius: 8px; background: transparent; color: #fff; font: 600 13px Inter, system-ui, sans-serif; cursor: pointer; }
.rn4 dialog { width: 100%; max-width: 100%; height: 100%; max-height: 100%; margin: 0; padding: 24px; box-sizing: border-box; border: 0; background: #0b1020; color: #fff; opacity: 0; transition: opacity .25s, overlay .25s allow-discrete, display .25s allow-discrete; }
.rn4 dialog[open] { opacity: 1; } @starting-style { .rn4 dialog[open] { opacity: 0; } }
.rn4 .close { float: right; width: 44px; height: 44px; border: 0; border-radius: 50%; background: #1e293b; color: #fff; font-size: 24px; cursor: pointer; }
.rn4 dialog nav { display: grid; gap: 6px; margin-top: 60px; }
.rn4 dialog nav a { color: #f8fafc; font-size: 34px; font-weight: 800; text-decoration: none; } .rn4 dialog nav a:hover { color: #fbbf24; }
.rn4 :focus-visible { outline: 2px solid #fbbf24; outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .rn4 dialog { transition: none; } }
var d = document.querySelector('.rn4 dialog');
document.querySelector('.rn4 .open').onclick = function () { d.showModal(); };
d.querySelector('.close').onclick = function () { d.close(); };
d.querySelectorAll('nav a').forEach(function (a) { a.onclick = function () { d.close(); }; });

11. Logo Above Links on Mobile

ResponsiveCentred

Some sites have few enough links that no hamburger is needed: on narrow containers the logo sits centred above a wrapping row of links, on wide ones it moves to the left. Every link stays visible at every size, which is the most usable option of all.

View code
<div class="rn5"><nav aria-label="Main"><a class="logo" href="#home">Olive &amp; Oak</a><ul><li><a href="#menu">Menu</a></li><li><a href="#book">Book</a></li><li><a href="#visit">Visit</a></li></ul></nav></div>
.rn5 { width: 560px; max-width: 100%; container-type: inline-size; font: 600 14px Inter, system-ui, sans-serif; }
.rn5 nav { display: grid; justify-items: center; gap: 8px; padding: 14px; border-bottom: 2px solid #1c1917; background: #fafaf9; }
.rn5 .logo { color: #1c1917; font: italic 700 22px Georgia, serif; text-decoration: none; }
.rn5 ul { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; margin: 0; padding: 0; list-style: none; }
.rn5 ul a { color: #44403c; text-decoration: none; } .rn5 ul a:hover { color: #1c1917; text-decoration: underline; }
.rn5 a:focus-visible { outline: 2px solid #1c1917; outline-offset: 3px; }
@container (min-width: 440px) { .rn5 nav { display: flex; justify-content: space-between; align-items: center; } }

12. No-JavaScript Menu with details

ResponsiveNo JS

A collapsible menu that needs no script at all: the menu is a details element whose summary is the Menu button, and on wide containers a container query hides the summary and shows the links as a row. It works even before JavaScript loads.

View code
<div class="rn6"><nav aria-label="Main"><a class="logo" href="#home">Atlas</a><details><summary>Menu</summary><ul><li><a href="#maps">Maps</a></li><li><a href="#guides">Guides</a></li><li><a href="#about">About</a></li></ul></details></nav></div>
.rn6 { width: 560px; max-width: 100%; container-type: inline-size; font: 600 14px Inter, system-ui, sans-serif; }
.rn6 nav { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 12px 14px; border-radius: 12px; background: #151b2e; }
.rn6 .logo { color: #fff; font-weight: 900; font-size: 18px; text-decoration: none; }
.rn6 summary { padding: 6px 12px; border: 1px solid #3a4670; border-radius: 8px; color: #fff; cursor: pointer; list-style: none; }
.rn6 summary::-webkit-details-marker { display: none; }
.rn6 ul { margin: 8px 0 0; padding: 0; list-style: none; } .rn6 ul a { display: block; padding: 8px 0; color: #cbd5e1; text-decoration: none; }
.rn6 :focus-visible { outline: 2px solid #93c5fd; outline-offset: 2px; border-radius: 6px; }
@container (min-width: 420px) {
  .rn6 nav { align-items: center; }
  .rn6 details summary { display: none; }
  .rn6 details::details-content { content-visibility: visible; display: contents; }
  .rn6 ul { display: flex; gap: 18px; margin: 0; }
}

13. Side Drawer Navigation

ResponsiveDrawer

The menu slides in from the left as a modal drawer over a dimmed page. The native dialog element handles focus trapping and Escape, the slide is a transform transition with @starting-style, and clicking the dimmed backdrop closes it.

View code
<div class="rn7"><button class="open"><span aria-hidden="true">☰</span> Menu</button><dialog aria-label="Menu"><nav aria-label="Main"><a href="#home" aria-current="page">Home</a><a href="#shop">Shop</a><a href="#orders">Orders</a><a href="#help">Help</a></nav><button class="close">Close</button></dialog></div>
.rn7 { font: 600 14px Inter, system-ui, sans-serif; }
.rn7 .open { padding: 9px 14px; border: 1px solid #d0d5dd; border-radius: 8px; background: #fff; font: inherit; cursor: pointer; }
.rn7 dialog { position: fixed; inset: 0 auto 0 0; width: min(240px, 80vw); height: 100%; max-height: none; margin: 0; padding: 20px; box-sizing: border-box; border: 0; background: #fff; transform: translateX(-100%); transition: transform .3s cubic-bezier(.2,.8,.2,1), overlay .3s allow-discrete, display .3s allow-discrete; }
.rn7 dialog[open] { transform: none; } @starting-style { .rn7 dialog[open] { transform: translateX(-100%); } }
.rn7 dialog::backdrop { background: rgba(16,24,40,.45); }
.rn7 nav { display: grid; gap: 4px; margin-bottom: 16px; }
.rn7 nav a { padding: 10px; border-radius: 8px; color: #344054; text-decoration: none; } .rn7 nav a[aria-current] { background: #f2f4f7; color: #101828; }
.rn7 .close { padding: 8px 12px; border: 1px solid #d0d5dd; border-radius: 8px; background: #fff; font: inherit; cursor: pointer; }
.rn7 :focus-visible { outline: 3px solid #84adff; outline-offset: 1px; }
@media (prefers-reduced-motion: reduce) { .rn7 dialog { transition: none; } }
var d = document.querySelector('.rn7 dialog');
document.querySelector('.rn7 .open').onclick = function () { d.showModal(); };
d.querySelector('.close').onclick = function () { d.close(); };
d.addEventListener('click', function (e) { if (e.target === d) d.close(); });

14. Sticky Navbar in a Scrolling Page

StickyNavbar

A navbar that stays at the top as the page scrolls, with position: sticky; top: 0 and a solid background so content does not show through. Because sticky stays in the flow, there is no gap or jump when it starts sticking.

View code
<div class="snb1" tabindex="0" role="region" aria-label="Page, scroll"><p class="hero">Hero area</p><nav aria-label="Main"><a href="#home">Home</a><a href="#menu">Menu</a><a href="#visit">Visit</a></nav><p>Content.</p><p>More content.</p><p>Even more content.</p></div>
.snb1 { width: 280px; max-width: 100%; height: 280px; overflow-y: auto; border: 1px solid #e4e7ec; border-radius: 14px; background: #fff; font: 14px Inter, system-ui, sans-serif; }
.snb1:focus-visible { outline: 3px solid #84adff; outline-offset: 2px; }
.snb1 .hero { display: grid; place-items: center; height: 120px; margin: 0; background: #fef3c7; color: #92400e; font-weight: 700; }
.snb1 nav { position: sticky; top: 0; display: flex; gap: 14px; padding: 12px 14px; background: #fff; border-bottom: 1px solid #e4e7ec; }
.snb1 nav a { color: #101828; font-weight: 600; text-decoration: none; }
.snb1 nav a:focus-visible { outline: 3px solid #84adff; outline-offset: 2px; }
.snb1 p:not(.hero) { margin: 0; padding: 40px 14px; color: #475467; border-bottom: 1px solid #f2f4f7; }

15. Hides on Scroll Down, Shows on Up

StickyScroll direction

The navbar slides away when you scroll down to read and comes back the moment you scroll up, saving space on small screens. A scroll listener compares positions; the bar never hides while anything inside it has keyboard focus.

View code
<div class="snb2" tabindex="0" role="region" aria-label="Article, scroll"><nav aria-label="Main"><a href="#home">Journal</a><a href="#subscribe">Subscribe</a></nav><article><p>Scroll down and the bar hides.</p><p>Scroll up a little and it returns.</p><p>Reading space matters on phones.</p><p>Keep scrolling.</p><p>Almost there.</p><p>The end.</p></article></div>
.snb2 { position: relative; width: 280px; max-width: 100%; height: 280px; overflow-y: auto; border-radius: 14px; background: #121828; font: 14px Inter, system-ui, sans-serif; }
.snb2:focus-visible { outline: 2px solid #a78bfa; outline-offset: 2px; }
.snb2 nav { position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; padding: 12px 14px; background: #1e2546; transition: transform .25s ease; }
.snb2.up nav { transform: translateY(-100%); }
.snb2 nav a { color: #f8fafc; font-weight: 700; text-decoration: none; } .snb2 nav a + a { color: #c4b5fd; }
.snb2 nav a:focus-visible { outline: 2px solid #c4b5fd; outline-offset: 2px; }
.snb2 article { padding: 0 14px; color: #cbd5e1; } .snb2 p { margin: 0; padding: 40px 0; }
@media (prefers-reduced-motion: reduce) { .snb2 nav { transition: none; } }
var box = document.querySelector('.snb2'), nav = box.querySelector('nav'), last = 0;
box.addEventListener('scroll', function () { var y = box.scrollTop; if (!nav.contains(document.activeElement)) box.classList.toggle('up', y > last && y > 60); last = y; }, { passive: true });

16. Navbar That Shrinks When Scrolled

StickyShrink

A tall header with a large logo becomes a slim bar once you scroll past the top. A class toggled by an IntersectionObserver sentinel changes the padding and logo size, and transform keeps the logo shrink smooth.

View code
<div class="snb3" tabindex="0" role="region" aria-label="Page, scroll"><span class="sent" aria-hidden="true"></span><nav aria-label="Main"><a class="logo" href="#home">Atlas</a><a href="#trips">Trips</a></nav><p>Scroll a little.</p><p>The header gets smaller.</p><p>More content.</p><p>More content.</p></div>
.snb3 { width: 280px; max-width: 100%; height: 280px; overflow-y: auto; border: 1px solid #e4e7ec; border-radius: 14px; background: #fff; font: 14px Inter, system-ui, sans-serif; }
.snb3:focus-visible { outline: 3px solid #84adff; outline-offset: 2px; }
.snb3 .sent { display: block; height: 1px; }
.snb3 nav { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; padding: 22px 14px; background: #0f766e; transition: padding .25s ease, box-shadow .25s; }
.snb3 .logo { color: #fff; font-size: 26px; font-weight: 900; text-decoration: none; transform-origin: left center; transition: transform .25s ease; }
.snb3 nav a + a { color: #ccfbf1; font-weight: 600; text-decoration: none; }
.snb3.small nav { padding: 10px 14px; box-shadow: 0 6px 12px -6px rgba(0,0,0,.3); } .snb3.small .logo { transform: scale(.7); }
.snb3 nav a:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.snb3 p { margin: 0; padding: 40px 14px; color: #475467; }
@media (prefers-reduced-motion: reduce) { .snb3 nav, .snb3 .logo { transition: none; } }
var box = document.querySelector('.snb3');
new IntersectionObserver(function (es) { box.classList.toggle('small', !es[0].isIntersecting); }, { root: box }).observe(box.querySelector('.sent'));

17. Translucent Blurred Navbar

StickyGlass

A sticky bar with a semi-transparent background and backdrop-filter: blur, so colourful content passes underneath as a soft blur. The background stays opaque enough on its own for the links to keep contrast if blur is unsupported.

View code
<div class="snb4" tabindex="0" role="region" aria-label="Gallery, scroll"><nav aria-label="Main"><a href="#home">Prism</a><a href="#gallery">Gallery</a></nav><div class="c"><i style="--g:#f97316"></i><i style="--g:#06b6d4"></i><i style="--g:#a855f7"></i><i style="--g:#22c55e"></i></div></div>
.snb4 { width: 280px; max-width: 100%; height: 280px; overflow-y: auto; border-radius: 14px; background: #fff; font: 14px Inter, system-ui, sans-serif; }
.snb4:focus-visible { outline: 3px solid #84adff; outline-offset: 2px; }
.snb4 nav { position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; padding: 12px 14px; background: rgba(255,255,255,.78); -webkit-backdrop-filter: blur(12px) saturate(1.6); backdrop-filter: blur(12px) saturate(1.6); border-bottom: 1px solid rgba(16,24,40,.08); }
.snb4 nav a { color: #101828; font-weight: 700; text-decoration: none; }
.snb4 nav a:focus-visible { outline: 3px solid #84adff; outline-offset: 2px; }
.snb4 .c { display: grid; gap: 10px; padding: 10px; } .snb4 i { display: block; height: 120px; border-radius: 12px; background: var(--g); }

18. Scrollspy Highlights the Section

StickyScrollspy

The sticky nav highlights the link for the section currently in view and moves aria-current with it, so the highlight and the announced state agree. An IntersectionObserver with a band in the middle of the view picks the active section.

View code
<div class="snb5" tabindex="0" role="region" aria-label="Guide, scroll"><nav aria-label="On this page"><a href="#snb5a" aria-current="true">Plan</a><a href="#snb5b">Build</a><a href="#snb5c">Launch</a></nav><section id="snb5a"><h3>Plan</h3><p>Define the goal.</p></section><section id="snb5b"><h3>Build</h3><p>Make the first version.</p></section><section id="snb5c"><h3>Launch</h3><p>Ship and measure.</p></section></div>
.snb5 { width: 280px; max-width: 100%; height: 280px; overflow-y: auto; border-radius: 14px; background: #121828; font: 14px Inter, system-ui, sans-serif; }
.snb5:focus-visible { outline: 2px solid #34d399; outline-offset: 2px; }
.snb5 nav { position: sticky; top: 0; display: flex; gap: 4px; padding: 8px; background: #121828; border-bottom: 1px solid #263048; }
.snb5 nav a { padding: 6px 10px; border-radius: 999px; color: #94a3b8; font-weight: 600; text-decoration: none; }
.snb5 nav a[aria-current] { background: #34d399; color: #052e16; }
.snb5 nav a:focus-visible { outline: 2px solid #34d399; outline-offset: 2px; }
.snb5 section { min-height: 220px; padding: 14px; } .snb5 h3 { margin: 0 0 4px; color: #fff; } .snb5 p { margin: 0; color: #94a3b8; }
var box = document.querySelector('.snb5'), links = box.querySelectorAll('nav a');
var io = new IntersectionObserver(function (es) { es.forEach(function (e) { if (!e.isIntersecting) return; links.forEach(function (l) { if (l.getAttribute('href') === '#' + e.target.id) l.setAttribute('aria-current', 'true'); else l.removeAttribute('aria-current'); }); }); }, { root: box, rootMargin: '-40% 0px -55% 0px' });
box.querySelectorAll('section').forEach(function (s) { io.observe(s); });
links.forEach(function (l) { l.onclick = function (e) { e.preventDefault(); var s = box.querySelector(l.getAttribute('href')); box.scrollTo({ top: s.offsetTop - 50, behavior: 'smooth' }); }; });

19. Sticky Bottom Tab Bar

StickyMobile

A mobile app tab bar that sticks to the bottom of the screen, with icons above short labels. Labels are always visible, because icon-only tab bars are harder to learn, and the bar includes safe-area padding for phones with a home indicator.

View code
<div class="snb6" tabindex="0" role="region" aria-label="App screen, scroll"><p>Feed item</p><p>Feed item</p><p>Feed item</p><p>Feed item</p><nav aria-label="App"><a href="#home" aria-current="page"><span aria-hidden="true">⌂</span>Home</a><a href="#search"><span aria-hidden="true">⌕</span>Search</a><a href="#saved"><span aria-hidden="true">♡</span>Saved</a><a href="#me"><span aria-hidden="true">☺</span>Profile</a></nav></div>
.snb6 { width: 260px; max-width: 100%; height: 280px; overflow-y: auto; border: 1px solid #e4e7ec; border-radius: 22px; background: #f9fafb; font: 12px Inter, system-ui, sans-serif; }
.snb6:focus-visible { outline: 3px solid #84adff; outline-offset: 2px; }
.snb6 p { margin: 10px; padding: 30px 12px; border-radius: 12px; background: #fff; color: #475467; }
.snb6 nav { position: sticky; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid #e4e7ec; }
.snb6 nav a { display: grid; justify-items: center; gap: 2px; padding: 4px 0; color: #475467; font-weight: 600; text-decoration: none; }
.snb6 nav span { font-size: 18px; line-height: 1; }
.snb6 nav a[aria-current] { color: #6941c6; }
.snb6 nav a:focus-visible { outline: 3px solid #d6bbfb; outline-offset: -3px; border-radius: 8px; }

20. Top Bar Scrolls Away, Main Nav Sticks

StickyTwo-tier

A thin utility bar (phone number, language) scrolls away normally while the main navigation below it sticks. Only the second element is sticky, which is all it takes, so the page keeps its main links without wasting space on the utilities.

View code
<div class="snb7" tabindex="0" role="region" aria-label="Page, scroll"><div class="util">Call us · 020 7946 0000 · EN</div><nav aria-label="Main"><a href="#home">Harbour Hotel</a><a href="#book">Book</a></nav><p>Rooms</p><p>Dining</p><p>Spa</p><p>Location</p></div>
.snb7 { width: 280px; max-width: 100%; height: 280px; overflow-y: auto; border-radius: 14px; background: #0f172a; font: 14px Inter, system-ui, sans-serif; }
.snb7:focus-visible { outline: 2px solid #fbbf24; outline-offset: 2px; }
.snb7 .util { padding: 6px 14px; background: #020617; color: #94a3b8; font-size: 12px; }
.snb7 nav { position: sticky; top: 0; display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; background: #1e293b; }
.snb7 nav a { color: #f8fafc; font-weight: 700; text-decoration: none; }
.snb7 nav a + a { padding: 6px 12px; border-radius: 8px; background: #fbbf24; color: #1c1917; }
.snb7 nav a:focus-visible { outline: 2px solid #fde68a; outline-offset: 2px; }
.snb7 p { margin: 0; padding: 40px 14px; color: #cbd5e1; border-bottom: 1px solid #1e293b; }

21. Frosted Glass Navbar

GlassNavbar

A navbar over colourful shapes with backdrop-filter: blur and a translucent white fill, the classic frosted glass. A thin light border on the top edge sells the glass edge, and the fill is strong enough that the links pass contrast even where blur is unsupported.

View code
<div class="gn1"><span class="b1" aria-hidden="true"></span><span class="b2" aria-hidden="true"></span><nav aria-label="Main"><a class="logo" href="#home">Lumen</a><a href="#features">Features</a><a href="#pricing">Pricing</a></nav></div>
.gn1 { position: relative; width: 420px; max-width: 100%; height: 220px; overflow: hidden; border-radius: 18px; background: #0b1020; font: 600 14px Inter, system-ui, sans-serif; }
.gn1 span { position: absolute; border-radius: 50%; }
.gn1 .b1 { width: 180px; height: 180px; left: -30px; top: 10px; background: #ec4899; } .gn1 .b2 { width: 200px; height: 200px; right: -40px; top: 40px; background: #06b6d4; }
.gn1 nav { position: absolute; left: 14px; right: 14px; top: 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; padding: 12px 16px; border: 1px solid rgba(255,255,255,.25); border-radius: 14px; background: rgba(15,23,42,.45); -webkit-backdrop-filter: blur(16px) saturate(1.5); backdrop-filter: blur(16px) saturate(1.5); }
.gn1 a { color: #fff; text-decoration: none; } .gn1 .logo { margin-right: auto; font-weight: 900; }
.gn1 a:focus-visible { outline: 2px solid #fff; outline-offset: 3px; border-radius: 4px; }

22. Floating Glass Pill

GlassFloating

A compact navbar that floats as a rounded pill, centred over the page with a little gap from the top. The glass tint is a light white with a soft shadow, a look that suits light, photo-heavy pages.

View code
<div class="gn2"><div class="photo" aria-hidden="true"></div><nav aria-label="Main"><a href="#work" aria-current="page">Work</a><a href="#about">About</a><a href="#contact">Contact</a></nav></div>
.gn2 { position: relative; width: 420px; max-width: 100%; height: 220px; overflow: hidden; border-radius: 18px; font: 600 14px Inter, system-ui, sans-serif; }
.gn2 .photo { position: absolute; inset: 0; background: linear-gradient(#fde68a 0 35%, #fb923c 35% 60%, #9a3412 60%); }
.gn2 nav { position: absolute; left: 50%; top: 16px; transform: translateX(-50%); display: flex; gap: 2px; padding: 5px; border: 1px solid rgba(255,255,255,.6); border-radius: 999px; background: rgba(255,255,255,.55); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); box-shadow: 0 8px 24px -10px rgba(0,0,0,.3); }
.gn2 a { padding: 7px 14px; border-radius: 999px; color: #1c1917; text-decoration: none; }
.gn2 a[aria-current] { background: #1c1917; color: #fff; }
.gn2 a:focus-visible { outline: 2px solid #1c1917; outline-offset: 2px; }

23. Liquid Glass Navbar

Liquid glassNavbar

The liquid glass look: a heavier blur, a bright specular highlight along the top edge, an inner glow and a subtle refraction-like gradient border. It is all layered box-shadows and a masked gradient border, with no images or SVG filters.

View code
<div class="gn3"><span class="o1" aria-hidden="true"></span><span class="o2" aria-hidden="true"></span><nav aria-label="Main"><a href="#home">Home</a><a href="#explore" aria-current="page">Explore</a><a href="#library">Library</a></nav></div>
.gn3 { position: relative; display: grid; place-items: center; width: 420px; max-width: 100%; height: 220px; overflow: hidden; border-radius: 18px; background: linear-gradient(135deg, #1e1b4b, #0f172a); font: 600 14px Inter, system-ui, sans-serif; }
.gn3 span { position: absolute; border-radius: 50%; filter: blur(4px); }
.gn3 .o1 { width: 140px; height: 140px; left: 40px; top: 20px; background: #a855f7; } .gn3 .o2 { width: 120px; height: 120px; right: 50px; bottom: 10px; background: #22d3ee; }
.gn3 nav { position: relative; display: flex; gap: 4px; padding: 6px; border-radius: 999px; background: linear-gradient(180deg, rgba(255,255,255,.22), rgba(255,255,255,.06)); -webkit-backdrop-filter: blur(22px) saturate(1.8); backdrop-filter: blur(22px) saturate(1.8); box-shadow: inset 0 1px 0 rgba(255,255,255,.55), inset 0 -1px 0 rgba(255,255,255,.12), inset 0 0 18px rgba(255,255,255,.12), 0 12px 30px -12px rgba(0,0,0,.6); }
.gn3 nav::before { content: ""; position: absolute; inset: 0; padding: 1px; border-radius: inherit; background: linear-gradient(135deg, rgba(255,255,255,.7), rgba(255,255,255,0) 40%, rgba(255,255,255,.35)); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0); pointer-events: none; }
.gn3 a { position: relative; padding: 8px 16px; border-radius: 999px; color: #fff; text-decoration: none; text-shadow: 0 1px 2px rgba(0,0,0,.4); }
.gn3 a[aria-current] { background: rgba(255,255,255,.22); box-shadow: inset 0 1px 0 rgba(255,255,255,.5); }
.gn3 a:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

24. Dark Smoked Glass Bar

GlassDark

Glass does not have to be white: a dark smoked tint over a bright photo gives strong contrast for white links and a more serious tone. The tint is rgba black at 55 percent, which keeps the links readable on the lightest part of any image.

View code
<div class="gn4"><div class="photo" aria-hidden="true"></div><nav aria-label="Main"><a class="logo" href="#home">ALPINE</a><a href="#stays">Stays</a><a href="#book">Book</a></nav></div>
.gn4 { position: relative; width: 420px; max-width: 100%; height: 220px; overflow: hidden; border-radius: 18px; font: 600 14px Inter, system-ui, sans-serif; }
.gn4 .photo { position: absolute; inset: 0; background: linear-gradient(#e0f2fe 0 45%, #f8fafc 45% 55%, #94a3b8 55%); }
.gn4 nav { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 16px; padding: 14px 18px; background: rgba(2,6,23,.55); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.gn4 a { color: #fff; text-decoration: none; } .gn4 .logo { margin-right: auto; letter-spacing: .2em; font-weight: 800; }
.gn4 a:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

25. Glass Navbar with Glass Dropdown

GlassDropdown

The dropdown under a glass navbar should be glass too, or it looks pasted on. Both share the same tint, blur and border tokens through custom properties, and the dropdown is a disclosure button with aria-expanded.

View code
<div class="gn5"><span class="bg" aria-hidden="true"></span><nav aria-label="Main"><a href="#home">Nova</a><div class="dd"><button aria-expanded="false" aria-controls="gn5m">Products</button><div id="gn5m" class="menu" hidden><a href="#editor">Editor</a><a href="#cloud">Cloud</a></div></div></nav></div>
.gn5 { --tint: rgba(15,23,42,.5); --bd: rgba(255,255,255,.22); position: relative; width: 420px; max-width: 100%; height: 260px; overflow: hidden; border-radius: 18px; font: 600 14px Inter, system-ui, sans-serif; }
.gn5 .bg { position: absolute; inset: 0; background: radial-gradient(circle at 30% 70%, #f43f5e, transparent 45%), radial-gradient(circle at 75% 40%, #6366f1, transparent 45%), #0b1020; }
.gn5 nav { position: absolute; left: 14px; right: 14px; top: 14px; display: flex; align-items: center; gap: 14px; padding: 10px 14px; border: 1px solid var(--bd); border-radius: 14px; background: var(--tint); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
.gn5 a, .gn5 button { color: #fff; text-decoration: none; }
.gn5 button { padding: 6px 10px; border: 0; border-radius: 8px; background: none; font: inherit; cursor: pointer; } .gn5 button[aria-expanded=true] { background: rgba(255,255,255,.12); }
.gn5 .dd { position: relative; }
.gn5 .menu { position: absolute; left: 0; top: calc(100% + 12px); display: grid; min-width: 150px; padding: 6px; border: 1px solid var(--bd); border-radius: 12px; background: var(--tint); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
.gn5 .menu[hidden] { display: none; }
.gn5 .menu a { padding: 8px 10px; border-radius: 8px; font-weight: 500; } .gn5 .menu a:hover { background: rgba(255,255,255,.12); }
.gn5 a:focus-visible, .gn5 button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
var b = document.querySelector('.gn5 button'), m = document.getElementById('gn5m');
b.onclick = function () { var o = b.getAttribute('aria-expanded') !== 'true'; b.setAttribute('aria-expanded', o); m.hidden = !o; };
document.addEventListener('keydown', function (e) { if (e.key === 'Escape' && !m.hidden) { b.click(); b.focus(); } });

26. Glass Dock with Hover Lift

GlassDock

A desktop-style dock of app icons on a glass shelf at the bottom, where the hovered or focused icon lifts and grows. Each icon is a link with a name, and a small dot under the current app marks it with aria-current as well.

View code
<div class="gn6"><span class="bg" aria-hidden="true"></span><nav aria-label="Apps"><a href="#mail" aria-label="Mail" aria-current="page">✉</a><a href="#notes" aria-label="Notes">✎</a><a href="#music" aria-label="Music">♫</a><a href="#photos" aria-label="Photos">❀</a></nav></div>
.gn6 { position: relative; display: grid; align-items: end; justify-items: center; width: 420px; max-width: 100%; height: 220px; padding-bottom: 14px; box-sizing: border-box; overflow: hidden; border-radius: 18px; }
.gn6 .bg { position: absolute; inset: 0; background: linear-gradient(160deg, #0ea5e9, #6366f1 50%, #ec4899); }
.gn6 nav { position: relative; display: flex; align-items: end; gap: 8px; padding: 8px 10px; border: 1px solid rgba(255,255,255,.35); border-radius: 20px; background: rgba(255,255,255,.2); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); }
.gn6 a { position: relative; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: rgba(255,255,255,.9); color: #1e1b4b; font-size: 20px; text-decoration: none; transition: transform .2s cubic-bezier(.2,.8,.2,1); }
.gn6 a[aria-current]::after { content: ""; position: absolute; bottom: -6px; width: 4px; height: 4px; border-radius: 50%; background: #fff; }
.gn6 a:hover, .gn6 a:focus-visible { transform: translateY(-8px) scale(1.15); }
.gn6 a:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .gn6 a { transition: none; } .gn6 a:hover, .gn6 a:focus-visible { transform: none; } }

27. Glass Segmented Navigation

GlassSegmented

A segmented control on glass where a brighter pill slides behind the selected item. The items are links with aria-current, the pill is a single element moved with transform, and its position is computed from the current link's box.

View code
<div class="gn7"><span class="bg" aria-hidden="true"></span><nav aria-label="View"><span class="pill" aria-hidden="true"></span><a href="#day" aria-current="page">Day</a><a href="#week">Week</a><a href="#month">Month</a></nav></div>
.gn7 { position: relative; display: grid; place-items: center; width: 380px; max-width: 100%; height: 180px; overflow: hidden; border-radius: 18px; font: 600 14px Inter, system-ui, sans-serif; }
.gn7 .bg { position: absolute; inset: 0; background: linear-gradient(135deg, #bbf7d0, #67e8f9 50%, #c4b5fd); }
.gn7 nav { position: relative; display: flex; padding: 4px; border: 1px solid rgba(255,255,255,.7); border-radius: 12px; background: rgba(255,255,255,.4); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.gn7 .pill { position: absolute; top: 4px; left: 0; height: calc(100% - 8px); border-radius: 9px; background: rgba(255,255,255,.95); box-shadow: 0 2px 6px rgba(15,23,42,.15); transition: transform .3s cubic-bezier(.2,.8,.2,1), width .3s; }
.gn7 a { position: relative; padding: 8px 16px; color: #0f172a; text-decoration: none; }
.gn7 a:focus-visible { outline: 2px solid #0f172a; outline-offset: 1px; border-radius: 8px; }
@media (prefers-reduced-motion: reduce) { .gn7 .pill { transition: none; } }
var nav = document.querySelector('.gn7 nav'), pill = nav.querySelector('.pill'), links = nav.querySelectorAll('a');
function to(a) { pill.style.width = a.offsetWidth + 'px'; pill.style.transform = 'translateX(' + a.offsetLeft + 'px)'; }
links.forEach(function (a) { a.onclick = function (e) { e.preventDefault(); links.forEach(function (x) { if (x === a) x.setAttribute('aria-current', 'page'); else x.removeAttribute('aria-current'); }); to(a); }; });
to(nav.querySelector('[aria-current]'));

28. Tab Bar with Centre Action

MobileTab bar

A five-slot bottom tab bar with a raised round button in the middle for the main action, such as posting. Every tab keeps a text label, the centre button has an accessible name, and the bar sits in a phone-shaped frame here.

View code
<div class="mn1"><div class="scr"></div><nav aria-label="App"><a href="#home" aria-current="page"><span aria-hidden="true">⌂</span>Home</a><a href="#explore"><span aria-hidden="true">◎</span>Explore</a><button aria-label="New post">+</button><a href="#inbox"><span aria-hidden="true">✉</span>Inbox</a><a href="#me"><span aria-hidden="true">☺</span>Me</a></nav></div>
.mn1 { display: grid; grid-template-rows: 1fr auto; width: 260px; max-width: 100%; height: 260px; border: 1px solid #e4e7ec; border-radius: 24px; overflow: hidden; background: #f9fafb; font: 600 11px Inter, system-ui, sans-serif; }
.mn1 nav { display: grid; grid-template-columns: repeat(5, 1fr); align-items: end; padding: 6px 4px 10px; background: #fff; border-top: 1px solid #e4e7ec; }
.mn1 a { display: grid; justify-items: center; gap: 2px; color: #475467; text-decoration: none; } .mn1 a span { font-size: 18px; line-height: 1; }
.mn1 a[aria-current] { color: #7f56d9; }
.mn1 button { justify-self: center; width: 50px; height: 50px; margin-top: -24px; border: 4px solid #fff; border-radius: 50%; background: #7f56d9; color: #fff; font-size: 26px; cursor: pointer; box-shadow: 0 6px 14px -6px #7f56d9; }
.mn1 :focus-visible { outline: 3px solid #d6bbfb; outline-offset: 1px; border-radius: 8px; } .mn1 button:focus-visible { border-radius: 50%; }

29. Menu in a Bottom Sheet

MobileBottom sheet

On phones the menu opens as a sheet sliding up from the bottom, where thumbs can reach every item. It is a modal dialog, so focus stays inside and Escape or the Close button dismisses it, and the sheet's slide is a transform with @starting-style.

View code
<div class="mn2"><button class="open">Menu</button><dialog aria-label="Menu"><span class="grab" aria-hidden="true"></span><nav aria-label="Main"><a href="#home">Home</a><a href="#bookings">Bookings</a><a href="#messages">Messages</a><a href="#settings">Settings</a></nav><button class="close">Close</button></dialog></div>
.mn2 { font: 600 15px Inter, system-ui, sans-serif; }
.mn2 .open { padding: 10px 16px; border: 0; border-radius: 10px; background: #f8fafc; color: #0f172a; font: inherit; cursor: pointer; }
.mn2 dialog { position: fixed; inset: auto 0 0 0; width: 100%; max-width: 100%; margin: 0; padding: 10px 18px 18px; box-sizing: border-box; border: 0; border-radius: 20px 20px 0 0; background: #151b2e; color: #fff; transform: translateY(100%); transition: transform .35s cubic-bezier(.2,.8,.2,1), overlay .35s allow-discrete, display .35s allow-discrete; }
.mn2 dialog[open] { transform: none; } @starting-style { .mn2 dialog[open] { transform: translateY(100%); } }
.mn2 dialog::backdrop { background: rgba(0,0,0,.5); }
.mn2 .grab { display: block; width: 40px; height: 5px; margin: 0 auto 12px; border-radius: 3px; background: #475569; }
.mn2 nav { display: grid; margin-bottom: 12px; }
.mn2 nav a { padding: 14px 4px; border-bottom: 1px solid #263048; color: #f1f5f9; text-decoration: none; }
.mn2 .close { width: 100%; padding: 12px; border: 0; border-radius: 12px; background: #263048; color: #fff; font: inherit; cursor: pointer; }
.mn2 :focus-visible { outline: 2px solid #93c5fd; outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .mn2 dialog { transition: none; } }
var d = document.querySelector('.mn2 dialog');
document.querySelector('.mn2 .open').onclick = function () { d.showModal(); };
d.querySelector('.close').onclick = function () { d.close(); };

30. Full-Screen Menu with Big Links

MobileFull screen

A mobile menu panel that fills the frame with large, well-spaced links and secondary links at the bottom. Large type makes the menu fast to scan and easy to tap, and the current page is marked with aria-current and an arrow.

View code
<div class="mn3"><nav aria-label="Main"><a href="#home" aria-current="page">Home</a><a href="#shop">Shop</a><a href="#stories">Stories</a><a href="#about">About</a></nav><nav class="sub" aria-label="Secondary"><a href="#help">Help</a><a href="#account">Account</a></nav></div>
.mn3 { display: grid; align-content: space-between; width: 260px; max-width: 100%; height: 300px; padding: 22px; box-sizing: border-box; border-radius: 22px; background: #fef3c7; font-family: Inter, system-ui, sans-serif; }
.mn3 nav { display: grid; gap: 4px; }
.mn3 a { color: #451a03; font-size: 30px; font-weight: 900; letter-spacing: -.02em; text-decoration: none; }
.mn3 a[aria-current]::after { content: " →"; color: #b45309; }
.mn3 .sub { display: flex; gap: 16px; } .mn3 .sub a { font-size: 14px; font-weight: 600; color: #92400e; }
.mn3 a:focus-visible { outline: 3px solid #b45309; outline-offset: 2px; border-radius: 4px; }

31. Swipeable Top Tabs

MobileTabs

Top tabs that scroll sideways when there are more than fit, with the selected tab underlined and scrolled into view when chosen. It uses the ARIA tabs pattern, so left and right arrows move between tabs on a keyboard.

View code
<div class="mn4"><div role="tablist" aria-label="Feed"><button role="tab" aria-selected="true" aria-controls="mn4p">For you</button><button role="tab" aria-selected="false" aria-controls="mn4p" tabindex="-1">Following</button><button role="tab" aria-selected="false" aria-controls="mn4p" tabindex="-1">Design</button><button role="tab" aria-selected="false" aria-controls="mn4p" tabindex="-1">Engineering</button><button role="tab" aria-selected="false" aria-controls="mn4p" tabindex="-1">Product</button></div><div role="tabpanel" id="mn4p" tabindex="0" aria-label="For you">Posts picked for you.</div></div>
.mn4 { width: 260px; max-width: 100%; border-radius: 16px; overflow: hidden; background: #111727; font: 600 14px Inter, system-ui, sans-serif; }
.mn4 [role=tablist] { display: flex; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid #263048; }
.mn4 [role=tablist]::-webkit-scrollbar { display: none; }
.mn4 [role=tab] { flex: none; padding: 12px 14px; border: 0; border-bottom: 2px solid transparent; background: none; color: #94a3b8; font: inherit; cursor: pointer; }
.mn4 [aria-selected=true] { border-bottom-color: #38bdf8; color: #fff; }
.mn4 [role=tabpanel] { padding: 18px 14px; color: #cbd5e1; font-weight: 400; }
.mn4 :focus-visible { outline: 2px solid #38bdf8; outline-offset: -2px; }
var tabs = document.querySelectorAll('.mn4 [role=tab]'), p = document.getElementById('mn4p');
function sel(i) { tabs.forEach(function (x, j) { x.setAttribute('aria-selected', i === j); x.tabIndex = i === j ? 0 : -1; }); p.textContent = tabs[i].textContent + ' posts.'; p.setAttribute('aria-label', tabs[i].textContent); tabs[i].focus(); tabs[i].scrollIntoView({ block: 'nearest', inline: 'center', behavior: 'smooth' }); }
tabs.forEach(function (t, i) { t.onclick = function () { sel(i); }; t.onkeydown = function (e) { var k = { ArrowRight: 1, ArrowLeft: -1 }[e.key]; if (k) { e.preventDefault(); sel((i + k + tabs.length) % tabs.length); } }; });

32. Back Header with Title and Action

MobileHeader

The header of a detail screen in a mobile web app: a back link on the left, the screen title centred and a single action on the right. The title is the page heading, and the back link names its destination rather than just saying Back.

View code
<header class="mn5"><a href="#orders" aria-label="Back to Orders"><span aria-hidden="true">‹</span> Orders</a><h3>Order #1042</h3><button>Share</button></header>
.mn5 { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; width: 300px; max-width: 100%; box-sizing: border-box; padding: 10px 12px; border-bottom: 1px solid #e4e7ec; background: #fff; font: 15px Inter, system-ui, sans-serif; }
.mn5 a { justify-self: start; color: #2563eb; font-weight: 600; text-decoration: none; } .mn5 a span { font-size: 22px; line-height: 0; vertical-align: -2px; }
.mn5 h3 { margin: 0; color: #101828; font-size: 16px; white-space: nowrap; }
.mn5 button { justify-self: end; padding: 6px 10px; border: 0; border-radius: 8px; background: none; color: #2563eb; font: 600 15px Inter, system-ui, sans-serif; cursor: pointer; }
.mn5 :focus-visible { outline: 3px solid #84adff; outline-offset: 2px; border-radius: 6px; }

33. Segmented Control

MobileSegmented

The iOS-style segmented control for switching views, built from radio buttons so only one segment can be on and arrow keys move between them. The selected segment's raised look comes from :has(:checked) on its label.

View code
<fieldset class="mn6"><legend class="sr">Show</legend><label><input type="radio" name="mn6" checked> Upcoming</label><label><input type="radio" name="mn6"> Past</label><label><input type="radio" name="mn6"> Drafts</label></fieldset>
.mn6 { display: flex; width: 280px; max-width: 100%; min-inline-size: 0; margin: 0; padding: 3px; box-sizing: border-box; border: 0; border-radius: 10px; background: #1e293b; font: 600 13px Inter, system-ui, sans-serif; }
.mn6 label { flex: 1; padding: 8px 6px; border-radius: 8px; color: #94a3b8; text-align: center; cursor: pointer; transition: background .2s, color .2s; }
.mn6 input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.mn6 label:has(:checked) { background: #f8fafc; color: #0f172a; box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.mn6 label:has(:focus-visible) { outline: 2px solid #93c5fd; outline-offset: 1px; }
.mn6 .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
@media (prefers-reduced-motion: reduce) { .mn6 label { transition: none; } }

34. Floating Bottom Nav Pill

MobileFloating

A bottom navigation that floats as a dark pill above the content, with the current item expanding to show its label while the others show only icons with hidden labels. The expanding label is a width transition on a span.

View code
<div class="mn7"><nav aria-label="App"><a href="#home" aria-current="page"><span class="i" aria-hidden="true">⌂</span><span class="l">Home</span></a><a href="#search"><span class="i" aria-hidden="true">⌕</span><span class="l">Search</span></a><a href="#saved"><span class="i" aria-hidden="true">♡</span><span class="l">Saved</span></a><a href="#profile"><span class="i" aria-hidden="true">☺</span><span class="l">Profile</span></a></nav></div>
.mn7 { display: grid; align-items: end; justify-items: center; width: 280px; max-width: 100%; height: 220px; padding-bottom: 14px; box-sizing: border-box; border-radius: 22px; background: linear-gradient(#f2f4f7, #e4e7ec); font: 600 13px Inter, system-ui, sans-serif; }
.mn7 nav { display: flex; gap: 2px; padding: 6px; border-radius: 999px; background: #101828; box-shadow: 0 10px 24px -10px rgba(16,24,40,.6); }
.mn7 a { display: flex; align-items: center; gap: 6px; padding: 9px 12px; border-radius: 999px; color: #98a2b3; text-decoration: none; }
.mn7 .i { font-size: 17px; line-height: 1; }
.mn7 .l { max-width: 0; overflow: hidden; white-space: nowrap; transition: max-width .3s ease; }
.mn7 a[aria-current] { background: #fff; color: #101828; } .mn7 a[aria-current] .l { max-width: 70px; }
.mn7 a:not([aria-current]) .l { position: absolute; width: 1px; height: 1px; clip: rect(0 0 0 0); }
.mn7 a:focus-visible { outline: 2px solid #84adff; outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .mn7 .l { transition: none; } }
var links = document.querySelectorAll('.mn7 a');
links.forEach(function (a) { a.onclick = function (e) { e.preventDefault(); links.forEach(function (x) { if (x === a) x.setAttribute('aria-current', 'page'); else x.removeAttribute('aria-current'); }); }; });

35. Hamburger to Cross

MenuAnimation

The classic three-line icon that morphs into an X when the menu opens. The middle bar fades out while the outer bars rotate into a cross, the button toggles aria-expanded, and its accessible name stays Menu in both states.

View code
<button class="hb" aria-expanded="false" aria-label="Menu"><span></span><span></span><span></span></button>
.hb { display: grid; gap: 6px; width: 52px; height: 52px; padding: 14px 13px; border: 1px solid #2f3749; border-radius: 14px; background: #151a26; cursor: pointer; }
.hb span { display: block; height: 3px; border-radius: 2px; background: #fff; transition: transform .25s, opacity .2s; }
.hb[aria-expanded=true] span:nth-child(1) { transform: translateY(9px) rotate(45deg); }
.hb[aria-expanded=true] span:nth-child(2) { opacity: 0; }
.hb[aria-expanded=true] span:nth-child(3) { transform: translateY(-9px) rotate(-45deg); }
.hb:focus-visible { outline: 2px solid #9db8ff; outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .hb span { transition: none; } }
const hb = document.querySelector('.hb');
hb.addEventListener('click', () => hb.setAttribute('aria-expanded', String(hb.getAttribute('aria-expanded') !== 'true')));

36. Hamburger to Arrow

MenuBack

A variation where the three lines become a left-pointing arrow, useful when opening a menu means navigating back. The top and bottom bars shorten and rotate towards the left end of the middle bar, all with transforms.

View code
<button class="ha" aria-expanded="false" aria-label="Menu"><span></span><span></span><span></span></button>
.ha { display: grid; gap: 6px; width: 52px; height: 52px; padding: 15px 13px; border: 0; border-radius: 50%; background: #101828; cursor: pointer; }
.ha span { display: block; height: 3px; border-radius: 2px; background: #fff; transform-origin: left center; transition: transform .25s, width .25s; }
.ha[aria-expanded=true] span:nth-child(1) { width: 60%; transform: translateY(3px) rotate(-40deg); }
.ha[aria-expanded=true] span:nth-child(3) { width: 60%; transform: translateY(-3px) rotate(40deg); }
.ha:focus-visible { outline: 2px solid #2563eb; outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .ha span { transition: none; } }
const ha = document.querySelector('.ha');
ha.addEventListener('click', () => ha.setAttribute('aria-expanded', String(ha.getAttribute('aria-expanded') !== 'true')));

37. Menu Button with Text Label

MenuUsability

Pairing the icon with the word Menu makes it clearer for people who do not recognise the three-line symbol. The visible text doubles as the accessible name, and the label changes to Close when the menu is open.

View code
<button class="hl" aria-expanded="false"><span class="ic" aria-hidden="true"><i></i><i></i><i></i></span><span class="tx">Menu</span></button>
.hl { display: inline-flex; align-items: center; gap: 10px; padding: 10px 16px; border: 1px solid #3a4256; border-radius: 999px; background: none; color: #fff; font: 700 14px Inter, system-ui, sans-serif; letter-spacing: .04em; text-transform: uppercase; cursor: pointer; }
.ic { display: grid; gap: 4px; width: 18px; }
.ic i { height: 2px; border-radius: 1px; background: currentColor; transition: transform .2s, opacity .2s; }
.hl[aria-expanded=true] .ic i:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.hl[aria-expanded=true] .ic i:nth-child(2) { opacity: 0; }
.hl[aria-expanded=true] .ic i:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
.hl:focus-visible { outline: 2px solid #fbbf24; outline-offset: 3px; }
const hl = document.querySelector('.hl');
hl.addEventListener('click', () => {
  const open = hl.getAttribute('aria-expanded') !== 'true';
  hl.setAttribute('aria-expanded', String(open));
  hl.querySelector('.tx').textContent = open ? 'Close' : 'Menu';
});

38. Hamburger with Slide-Out Menu

MenuMobile

A complete mobile header: the hamburger opens a panel that slides in from the left. The button controls the panel with aria-controls and aria-expanded, Escape closes the panel and returns focus to the button, and the links are a normal list.

View code
<div class="ph-wrap">
  <header class="mh">
    <b>Fernhill</b>
    <button class="mb" aria-expanded="false" aria-controls="mnav" aria-label="Menu"><span></span><span></span><span></span></button>
  </header>
  <nav id="mnav" class="panel" aria-label="Main">
    <ul><li><a href="#">Shop</a></li><li><a href="#">Workshops</a></li><li><a href="#">About</a></li><li><a href="#">Contact</a></li></ul>
  </nav>
</div>
.ph-wrap { position: relative; width: 300px; height: 320px; overflow: hidden; border-radius: 22px; background: #f9fafb; box-shadow: 0 0 0 8px #101828; font-family: Inter, system-ui, sans-serif; }
.mh { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; background: #fff; border-bottom: 1px solid #eef0f4; }
.mh b { color: #101828; }
.mb { display: grid; gap: 5px; width: 40px; height: 40px; padding: 11px 10px; border: 0; border-radius: 10px; background: #f2f4f7; cursor: pointer; }
.mb span { height: 2px; background: #101828; }
.mb:focus-visible { outline: 2px solid #2563eb; }
.panel { position: absolute; top: 69px; bottom: 0; left: 0; width: 78%; background: #101828; transform: translateX(-100%); transition: transform .3s; visibility: hidden; }
.panel.open { transform: none; visibility: visible; }
.panel ul { margin: 0; padding: 12px 0; list-style: none; }
.panel a { display: block; padding: 14px 22px; color: #fff; font-weight: 600; text-decoration: none; }
.panel a:hover, .panel a:focus-visible { background: #1d2939; outline: none; }
@media (prefers-reduced-motion: reduce) { .panel { transition: none; } }
const mb = document.querySelector('.mb'), panel = document.getElementById('mnav');
function set(open) {
  mb.setAttribute('aria-expanded', String(open));
  panel.classList.toggle('open', open);
  if (open) panel.querySelector('a').focus();
}
mb.addEventListener('click', () => set(mb.getAttribute('aria-expanded') !== 'true'));
document.addEventListener('keydown', e => { if (e.key === 'Escape' && panel.classList.contains('open')) { set(false); mb.focus(); } });

39. Full-Screen Overlay Menu

MenuOverlay

A bold full-screen menu for portfolio and agency sites: large links fade in one after another over a dark overlay. The stagger uses a custom property per item for its delay, and the overlay is hidden from the keyboard until it opens.

View code
<div class="fs-wrap">
  <button class="fsb" aria-expanded="false" aria-controls="fsm">Menu</button>
  <nav class="fsm" id="fsm" aria-label="Main">
    <a href="#" style="--i:0">Work</a><a href="#" style="--i:1">Studio</a><a href="#" style="--i:2">Journal</a><a href="#" style="--i:3">Say hello</a>
  </nav>
</div>
.fs-wrap { position: relative; width: min(460px, 94vw); height: 330px; overflow: hidden; border-radius: 18px; background: #0b0d14; font-family: Inter, system-ui, sans-serif; }
.fsb { position: absolute; top: 16px; right: 16px; z-index: 2; padding: 8px 16px; border: 1px solid #fff; border-radius: 999px; background: none; color: #fff; font: 700 13px Inter, sans-serif; cursor: pointer; }
.fsb:focus-visible { outline: 2px solid #f472b6; outline-offset: 3px; }
.fsm { position: absolute; inset: 0; display: grid; align-content: center; gap: 4px; padding: 0 34px; background: linear-gradient(135deg, #1e1b4b, #0b0d14); visibility: hidden; opacity: 0; transition: opacity .3s, visibility .3s; }
.fsm.open { visibility: visible; opacity: 1; }
.fsm a { color: #fff; font-size: 38px; font-weight: 800; letter-spacing: -.02em; text-decoration: none; opacity: 0; transform: translateY(14px); transition: opacity .4s, transform .4s, color .2s; transition-delay: calc(var(--i) * 70ms); }
.fsm.open a { opacity: 1; transform: none; }
.fsm a:hover, .fsm a:focus-visible { color: #f472b6; outline: none; }
@media (prefers-reduced-motion: reduce) { .fsm, .fsm a { transition: none; } }
const fb = document.querySelector('.fsb'), fm = document.getElementById('fsm');
fb.addEventListener('click', () => {
  const open = !fm.classList.contains('open');
  fm.classList.toggle('open', open);
  fb.setAttribute('aria-expanded', String(open));
  fb.textContent = open ? 'Close' : 'Menu';
});

40. Kebab and Meatball Icons

IconOverflow

Overflow menu triggers drawn entirely in CSS: three vertical dots (kebab) and three horizontal dots (meatball), made from one dot plus two box-shadow copies. Each is a real button with an accessible name such as More options.

View code
<div class="dots-row">
  <button class="kb" aria-label="More options" aria-haspopup="menu"><span></span></button>
  <button class="mt" aria-label="More actions" aria-haspopup="menu"><span></span></button>
</div>
.dots-row { display: flex; gap: 20px; }
.dots-row button { display: grid; place-items: center; width: 44px; height: 44px; border: 1.5px solid #d0d5dd; border-radius: 12px; background: #fff; cursor: pointer; }
.dots-row button:hover { background: #f2f4f7; }
.dots-row button:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
.dots-row span { width: 4px; height: 4px; border-radius: 50%; background: #101828; }
.kb span { box-shadow: 0 -7px 0 #101828, 0 7px 0 #101828; }
.mt span { box-shadow: -7px 0 0 #101828, 7px 0 0 #101828; }

41. Squeeze Hamburger

MenuAnimation

The bars first squeeze together into a single line, then rotate into an X, a two-stage motion made with transition delays that run in reverse when closing. It feels more mechanical and deliberate than a straight rotation.

View code
<button class="sq" aria-expanded="false" aria-label="Menu"><span></span><span></span><span></span></button>
.sq { display: grid; place-items: center; width: 54px; height: 54px; border: 0; border-radius: 12px; background: #f97316; cursor: pointer; }
.sq span { grid-area: 1 / 1; display: block; width: 26px; height: 3px; border-radius: 2px; background: #1a0d03; transition: transform .2s, opacity .2s; transition-delay: .2s, .2s; }
.sq span:nth-child(1) { transform: translateY(-8px); }
.sq span:nth-child(3) { transform: translateY(8px); }
.sq[aria-expanded=true] span { transition-delay: 0s, 0s; }
.sq[aria-expanded=true] span:nth-child(1) { transform: rotate(45deg); transition: transform .2s .2s; }
.sq[aria-expanded=true] span:nth-child(2) { opacity: 0; }
.sq[aria-expanded=true] span:nth-child(3) { transform: rotate(-45deg); transition: transform .2s .2s; }
.sq:focus-visible { outline: 2px solid #fed7aa; outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .sq span { transition: none !important; } }
const sq = document.querySelector('.sq');
sq.addEventListener('click', () => sq.setAttribute('aria-expanded', String(sq.getAttribute('aria-expanded') !== 'true')));

42. Hamburger with Dropdown List

MenuDropdown

A compact menu that drops down below the button instead of sliding in, suited to simple sites with four or five pages. Clicking outside closes it, Escape closes it and returns focus, and the open list is a normal set of links.

View code
<div class="dd">
  <button class="ddb" aria-expanded="false" aria-controls="ddl"><span aria-hidden="true">&#9776;</span> Menu</button>
  <ul class="ddl" id="ddl" hidden>
    <li><a href="#">Recipes</a></li><li><a href="#">Meal plans</a></li><li><a href="#">Shopping lists</a></li><li><a href="#">Account</a></li>
  </ul>
</div>
.dd { position: relative; font-family: Inter, system-ui, sans-serif; }
.ddb { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border: 1.5px solid #d0d5dd; border-radius: 10px; background: #fff; color: #101828; font: 700 14px Inter, sans-serif; cursor: pointer; }
.ddb:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
.ddl { position: absolute; top: calc(100% + 6px); left: 0; min-width: 190px; margin: 0; padding: 6px; list-style: none; border: 1px solid #e4e7ec; border-radius: 12px; background: #fff; box-shadow: 0 16px 36px -14px rgba(16,24,40,.35); }
.ddl a { display: block; padding: 10px 12px; border-radius: 8px; color: #344054; font-size: 14px; text-decoration: none; }
.ddl a:hover, .ddl a:focus-visible { background: #f2f4f7; color: #101828; outline: none; }
const db = document.querySelector('.ddb'), dl = document.getElementById('ddl');
function setOpen(o) { dl.hidden = !o; db.setAttribute('aria-expanded', String(o)); }
db.addEventListener('click', () => setOpen(dl.hidden));
document.addEventListener('click', e => { if (!e.target.closest('.dd')) setOpen(false); });
document.addEventListener('keydown', e => { if (e.key === 'Escape' && !dl.hidden) { setOpen(false); db.focus(); } });

About these CSS Navigation

Navigation must be accessible first

Navigation is how people move through a site, so a broken menu breaks the whole visit. Use real links and buttons, mark the current page with aria-current="page", give the navigation a label such as aria-label="Main", and make sure every control is reachable with the Tab key and shows a visible focus ring.

Mobile menus need a real button

The menu toggle in the navbar demo is a <button> with aria-expanded and aria-controls, so assistive technology announces whether the menu is open. The Escape key closes it and returns focus to the button, which is what keyboard users expect from any pop-up.

Use native elements where they exist

The accordion uses <details> and <summary>, which browsers already make keyboard accessible and announce correctly, with no JavaScript. Native elements are less code to maintain and often more robust than custom widgets.

Breadcrumbs and pagination help search engines too

Breadcrumbs inside a nav with an ordered list, and pagination with real links, give search engines a clear map of your site's structure. Pair breadcrumbs with BreadcrumbList structured data for the best chance of rich results.

Frequently asked questions

Are the CSS-only tabs accessible?

They work with the keyboard and are fine for simple content panels. For complex applications, add the full ARIA tabs pattern with JavaScript so screen readers announce tab and panel roles.

How do I make only one accordion item open?

Give every details element the same name attribute. Current browsers then close the others when one opens, with no script.

Do these work on mobile?

Yes. Every control has a touch target of at least 40px, and the navbar collapses into a menu below 600px.