Part of the Webcore kit
HTML
<nav class="tv-webcore-menubar" aria-label="Site">
<a class="tv-webcore-menubar-brand" href="#">☾ my homepage</a>
<ul class="tv-webcore-menubar-list">
<li><a class="tv-webcore-menubar-item" href="#" aria-current="page">home</a></li>
<li><a class="tv-webcore-menubar-item" href="#">about me</a></li>
<li>
<details class="tv-webcore-menubar-menu">
<summary class="tv-webcore-menubar-item">stuff</summary>
<ul class="tv-webcore-menubar-dropdown">
<li><a class="tv-webcore-menubar-option" href="#">art.gallery</a></li>
<li><a class="tv-webcore-menubar-option" href="#">music.box</a></li>
<li><a class="tv-webcore-menubar-option" href="#">shrines</a></li>
</ul>
</details>
</li>
<li><a class="tv-webcore-menubar-item" href="#">guestbook</a></li>
</ul>
</nav>
CSS
/* A retro OS menu bar for site links: a brand on the left, menu items that invert on hover, one dropdown. */
.tv-webcore-menubar {
--tv-webcore-menubar-face: var(--tv-webcore-pink, #f7b5e4);
display: flex;
flex-wrap: wrap;
align-items: stretch;
gap: 4px 14px;
box-sizing: border-box;
width: 100%;
padding: 3px 6px;
border: 1px solid var(--tv-webcore-navy, #2c2b9f);
background: var(--tv-webcore-menubar-face, #f7b5e4);
color: var(--tv-webcore-navy, #2c2b9f);
font: 14px/1.2 "Lucida Console", "Courier New", ui-monospace, monospace;
letter-spacing: 0.04em;
box-shadow: 3px 3px 0 color-mix(in srgb, var(--tv-webcore-navy, #2c2b9f) 25%, transparent);
}
.tv-webcore-menubar-brand {
display: inline-flex;
align-items: center;
min-height: 2.25rem;
padding: 0 8px;
border-right: 1px dotted var(--tv-webcore-navy, #2c2b9f);
color: inherit;
font-weight: 700;
text-decoration: none;
text-transform: uppercase;
}
.tv-webcore-menubar-list {
display: flex;
flex-wrap: wrap;
align-items: stretch;
gap: 2px;
margin: 0;
padding: 0;
list-style: none;
}
.tv-webcore-menubar-list > li {
position: relative;
display: flex;
}
.tv-webcore-menubar-item {
display: inline-flex;
align-items: center;
min-height: 2.25rem;
padding: 0 10px;
color: inherit;
text-decoration: none;
cursor: pointer;
list-style: none;
}
.tv-webcore-menubar-item::-webkit-details-marker {
display: none;
}
/* The current page is underlined; hover and the open menu invert to navy. */
.tv-webcore-menubar-item[aria-current="page"] {
text-decoration: underline;
text-decoration-thickness: 2px;
text-underline-offset: 4px;
}
.tv-webcore-menubar-item:hover,
.tv-webcore-menubar-menu[open] > .tv-webcore-menubar-item {
background: var(--tv-webcore-navy, #2c2b9f);
color: var(--tv-webcore-paper, #ffffff);
}
.tv-webcore-menubar-menu > .tv-webcore-menubar-item::after {
content: "";
margin-left: 8px;
border: 4px solid transparent;
border-top-color: currentColor;
border-bottom: 0;
}
.tv-webcore-menubar-dropdown {
position: absolute;
top: 100%;
left: 0;
z-index: 2;
min-width: 11rem;
margin: 3px 0 0;
padding: 3px;
border: 1px solid var(--tv-webcore-navy, #2c2b9f);
background: var(--tv-webcore-paper, #ffffff);
list-style: none;
box-shadow: 3px 3px 0 color-mix(in srgb, var(--tv-webcore-navy, #2c2b9f) 30%, transparent);
}
.tv-webcore-menubar-option {
display: flex;
align-items: center;
min-height: 2.25rem;
padding: 0 10px;
color: inherit;
text-decoration: none;
}
.tv-webcore-menubar-option:hover {
background: var(--tv-webcore-menubar-face, #f7b5e4);
}
.tv-webcore-menubar a:focus-visible,
.tv-webcore-menubar summary:focus-visible {
outline: 2px dashed var(--tv-webcore-navy, #2c2b9f);
outline-offset: -3px;
}
.tv-webcore-menubar--lilac {
--tv-webcore-menubar-face: var(--tv-webcore-lilac, #a49bf3);
}
.tv-webcore-menubar--grey {
--tv-webcore-menubar-face: var(--tv-webcore-grey, #d9d9e5);
}
Usage & credits
- Use when
- The top navigation of a personal site, fan page or Y2K landing page.
- Avoid when
- Deep navigation trees; one dropdown level is the most it handles well.
- Requires
- The dropdown is a native details element: it opens and closes on click or Enter, and stays open until closed. · Mark the current page with aria-current="page".
- From
- Luna UI