Nav
Free · MITHeadless, accessible, and styled entirely through the attribute surface below — bring your own CSS system, or start from the reference theme.
Install
Without a flag you get no styling at all — plain HTML carrying the attribute surface below. --theme copies the same theme in two dialects;--bridge lumos re-points either one onto Lumos for Astro's tokens (it needs a theme to re-point, and Lumos itself, already in your project).
Unstyled — behavior only, you write the CSS
npx astrocraft-ui add navigation/navPlain-CSS theme — no build step
npx astrocraft-ui add navigation/nav --theme cssTailwind theme — needs Tailwind v4
npx astrocraft-ui add navigation/nav --theme tailwindPlain-CSS theme, re-pointed onto Lumos tokens
npx astrocraft-ui add navigation/nav --theme css --bridge lumosTailwind theme, re-pointed onto Lumos tokens
npx astrocraft-ui add navigation/nav --theme tailwind --bridge lumosLive demo
Nav
The primitive is a plain route-driven list of links; this dev page wires clicks below so you can preview the active state moving between variants.
Attribute surface
With no class-merging machinery, these attributes are the whole extension point. State is a data-attribute or a native attribute; visibility is the hiddenattribute. Generated from source by pnpm slots.
| Component | Slots | Variants | Runtime state | Native state |
|---|---|---|---|---|
| `Nav.astro` | `nav` `nav-list` | `data-orientation`: `horizontal` · `vertical` | — | — |
| `NavItem.astro` | `nav-item` | — | — | — |
| `NavLink.astro` | `nav-link` | `data-variant`: `underline` · `pills` · `segment` | — | — |
Source
What the command copies — 4 files, alias-free so the copy lands standing alone. This is the whole component; there is nothing else.
---
// src/components/ui/navigation/nav/Nav.astro — headless primitive (see ../../README.md).
// Static navigation list (<nav> + <ul>). Compose NavItem / NavLink. Active state is the caller's
// job via `aria-current="page"` on the link (route-driven, zero-JS — the platform models it).
import type { HTMLAttributes } from "astro/types";
type Props = HTMLAttributes<"nav"> & { orientation?: "horizontal" | "vertical" };
const { orientation = "horizontal", class: className, ...rest } = Astro.props;
---
<nav data-slot="nav" {...rest}>
<ul class={className} data-slot="nav-list" data-orientation={orientation}>
<slot />
</ul>
</nav>
---
// src/components/ui/navigation/nav/NavItem.astro — Nav compound part (see ../../README.md).
import type { HTMLAttributes } from "astro/types";
type Props = HTMLAttributes<"li">;
const { class: className, ...rest } = Astro.props;
---
<li class={className} data-slot="nav-item" {...rest}>
<slot />
</li>
---
// src/components/ui/navigation/nav/NavLink.astro — Nav compound part (see ../../README.md).
// Active state = `aria-current="page"` set by the caller — the platform already models it, so no
// "active" prop and no data attribute duplicating it. A theme styles hover on non-active links with
// `[data-slot="nav-link"]:not([aria-current="page"]):hover`, which is what the old
// `not-aria-[current=page]:hover:` utility compiled to.
import type { HTMLAttributes } from "astro/types";
type Props = HTMLAttributes<"a"> & {
href: string;
variant?: "underline" | "pills" | "segment";
};
const { variant = "underline", href, class: className, ...rest } = Astro.props;
---
<a href={href} class={className} data-slot="nav-link" data-variant={variant} {...rest}>
<slot />
</a>
import Nav from "./Nav.astro";
import NavItem from "./NavItem.astro";
import NavLink from "./NavLink.astro";
export { Nav, NavItem, NavLink };
export default Nav;
What you get
The component source, copied into your project by npx astrocraft-ui add navigation/nav — no package dependency, no CSS to fight. Whatever the paid blocks compose, this is it.