---
import { TAB_ICONS } from "../../docs-icons";
import { DOCS_TABS, DOCS_TAB_GROUPS, activeTab, groupTabs } from "../../docs-tabs";
const start = DOCS_TABS.filter((tab) => tab.slot === "start");
const current = activeTab(Astro.url.pathname);
---
<nav class="alc-tabs" aria-label="Documentation sections">
<div class="alc-tabs__group">
{
start.map((tab) => (
<a
href={tab.href}
class:list={["alc-tabs__tab", { "alc-tabs__tab--active": tab.label === current.label }]}
aria-current={tab.label === current.label ? "true" : undefined}
>
{TAB_ICONS[tab.label] && (
<svg
class="alc-tabs__icon"
aria-hidden="true"
width="14"
height="14"
viewBox="0 0 24 24"
set:html={TAB_ICONS[tab.label]}
/>
)}
{tab.label}
</a>
))
}
{/* One hover dropdown per hub category (single-hub categories
share "More"); the group you're in is underlined and names the
current hub ("Clouds · AWS"). */}
{
DOCS_TAB_GROUPS.map((group) => {
const activeHere = groupTabs(group).some((tab) => tab.label === current.label);
return (
<div class="alc-tabs__menu-root">
<button
type="button"
class:list={["alc-tabs__tab", "alc-tabs__trigger", { "alc-tabs__tab--active": activeHere }]}
aria-haspopup="true"
>
{group.label}
{activeHere && <span class="alc-tabs__trigger-current">{current.label}</span>}
<svg
class="alc-tabs__chevron"
aria-hidden="true"
width="12"
height="12"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="m6 9 6 6 6-6" />
</svg>
</button>
<div class="alc-tabs__menu">
{group.sections.map((section) => (
<div class="alc-tabs__menu-section">
{section.heading && <div class="alc-tabs__menu-heading">{section.heading}</div>}
{section.tabs.map((tab) => (
<a
href={tab.href}
class:list={["alc-tabs__menu-item", { "alc-tabs__menu-item--active": tab.label === current.label }]}
aria-current={tab.label === current.label ? "true" : undefined}
>
{TAB_ICONS[tab.label] && (
<svg
class="alc-tabs__icon"
aria-hidden="true"
width="16"
height="16"
viewBox="0 0 24 24"
set:html={TAB_ICONS[tab.label]}
/>
)}
<span class="alc-tabs__menu-text">
<span>{tab.label}</span>
{tab.hint && <span class="alc-tabs__menu-hint">{tab.hint}</span>}
</span>
</a>
))}
</div>
))}
</div>
</div>
);
})
}
</div>
</nav>
<style>
.alc-tabs {
display: flex;
align-items: stretch;
gap: 16px;
height: var(--alc-tabs-height, 2.5rem);
margin: 0 calc(-1 * var(--sl-nav-pad-x));
padding: 0 calc(var(--sl-nav-pad-x) - 12px);
}
.alc-tabs__group {
display: flex;
align-items: stretch;
gap: 2px;
}
.alc-tabs__tab {
display: inline-flex;
align-items: center;
gap: 7px;
padding: 0 12px;
font-size: 13.5px;
color: var(--alc-fg-2);
text-decoration: none;
border: 0;
border-bottom: 2px solid transparent;
background: transparent;
font-family: inherit;
cursor: pointer;
white-space: nowrap;
transition: color var(--alc-dur) var(--alc-ease);
}
.alc-tabs__tab:hover {
color: var(--alc-accent-deep);
}
.alc-tabs__tab--active {
color: var(--alc-accent-deep);
font-weight: 500;
border-bottom-color: var(--alc-accent-deep);
}
.alc-tabs__icon {
flex-shrink: 0;
opacity: 0.85;
}
.alc-tabs__chevron {
margin-inline-start: -2px;
opacity: 0.7;
transition: transform var(--alc-dur) var(--alc-ease);
}
.alc-tabs__menu-root {
position: relative;
display: flex;
align-items: stretch;
}
.alc-tabs__trigger {
user-select: none;
}
/* "Clouds · AWS" — names the hub you're in without a tab per hub. */
.alc-tabs__trigger-current::before {
content: "·";
margin-inline-end: 7px;
color: var(--alc-fg-4);
font-weight: 400;
}
/* Menus open on hover and collapse as soon as the pointer leaves the
trigger + menu. Keyboard users open them by tabbing in (:focus-visible
only, so a mouse click doesn't pin a menu open after moving off). */
.alc-tabs__menu-root:hover > .alc-tabs__trigger,
.alc-tabs__menu-root:has(:focus-visible) > .alc-tabs__trigger {
color: var(--alc-accent-deep);
}
.alc-tabs__menu-root:hover .alc-tabs__chevron,
.alc-tabs__menu-root:has(:focus-visible) .alc-tabs__chevron {
transform: rotateZ(180deg);
}
.alc-tabs__menu-root:hover > .alc-tabs__menu,
.alc-tabs__menu-root:has(:focus-visible) > .alc-tabs__menu {
display: block;
}
.alc-tabs__menu {
display: none;
position: absolute;
top: 100%;
inset-inline-start: 0;
min-width: 300px;
/* The menu opens directly below the fixed header; cap it to the
remaining viewport and scroll so short windows don't clip items. */
max-height: calc(100dvh - var(--sl-nav-height) - 1rem);
overflow-y: auto;
overscroll-behavior: contain;
z-index: 30;
background: var(--alc-bg);
border: 1px solid var(--alc-hairline-2);
border-radius: 10px;
padding: 6px;
box-shadow: var(--alc-shadow-md, 0 8px 24px rgb(0 0 0 / 0.12));
}
.alc-tabs__menu-section + .alc-tabs__menu-section {
border-top: 1px solid var(--alc-hairline);
margin-top: 6px;
padding-top: 6px;
}
.alc-tabs__menu-heading {
padding: 4px 10px;
font-size: 10.5px;
font-weight: 600;
letter-spacing: 0.07em;
text-transform: uppercase;
color: var(--alc-fg-4);
}
.alc-tabs__menu-item {
display: flex;
align-items: flex-start;
gap: 11px;
padding: 7px 10px;
border-radius: 7px;
font-size: 13px;
color: var(--alc-fg-2);
text-decoration: none;
}
.alc-tabs__menu-item > .alc-tabs__icon {
margin-block-start: calc((1lh - 16px) / 2);
}
.alc-tabs__menu-item:hover {
color: var(--alc-accent-deep);
background: var(--alc-bg-elev-1);
}
.alc-tabs__menu-item--active {
color: var(--alc-accent-deep);
font-weight: 500;
background: color-mix(in srgb, var(--alc-accent-deep) 10%, transparent);
}
/* Stacked label + hint: every row renders the same height regardless
of hint length; a too-long hint ellipsizes instead of wrapping. */
.alc-tabs__menu-text {
display: flex;
flex-direction: column;
gap: 1px;
min-width: 0;
}
.alc-tabs__menu-hint {
font-size: 11px;
color: var(--alc-fg-4);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
/* Below 72rem the category row no longer fits: product navigation moves
to the MobileTabSwitcher at the top of the sidebar / hamburger drawer
instead of a horizontally scrollable strip nothing signals you can
scroll. Keep in sync with MobileTabSwitcher.astro and custom.css. */
@media (max-width: 72rem) {
.alc-tabs {
display: none;
}
}
</style>