AppNavbar
A floating nav capsule that darkens past the hero — labels fold shut without unmounting, and a single pill travels between links instead of fading in under each one.
Install: pnpm add-component AppNavbar
Live bar
A screen with its own scroller, so the contract can be demonstrated without scrolling this page. Every prop below is live.
Basic usage
Branding is a slot, so the bar carries whatever lockup you have. The slot receives `compact`, which is what lets a lockup clip back to its mark as the bar contracts.
Labels fold, they do not unmount
Each collapsing label stays in the DOM at max-width 0. Removing it would strip the control's accessible name the moment the bar contracts, leaving a screen reader with an icon and nothing else. The padding sits on an inner span, not the collapsing one — with border-box a padded box cannot be narrower than its own padding, so max-w-0 on a ps-2 span still measures 8px and pushes the icon off centre by exactly that much.
Inside an app shell
When the page scrolls inside a container rather than the document, hand the bar that container. Without it the bar reads the document's scroll offset, which never moves, and it stays at its resting size forever.
API
items(NavItem[]): The centred nav links. Each needs a label and a `to`; `exact` and `disabled` are optional. Matching is on a `/` boundary, so `/projects-archive` does not light up `/projects`.actions(NavAction[]): Trailing controls. An action with `to` is a link, one with only `onClick` is a button. `variant: "solid"` is the bar's one filled element — use it for a single call to action. `keepLabel` opts an action out of folding.tone('dark' | 'surface'): surface is the raised surface of the preset, with its border and shadow. dark is an inverse capsule for a page that opens on a light hero: ink in light mode, the raised surface in dark mode, with an inverse call to action.floating(boolean): A capsule inset from every edge, or a flush full-width bar. Floating is the default because a rule across the top of a hero cuts the frame in half.position('top' | 'bottom'): Which edge the bar pins to. The menu panel opens away from it either way.width / compactWidth('sm' | 'md' | 'lg' | 'xl' | 'full'): Measure at rest and once contracted. At rest it should match your content column, so the capsule edges land on the same grid every section below uses. compactWidth is unset by default, so the bar keeps its measure; a set value is a snap, not an animation.contract(boolean): Set false to pin the bar at its resting size and never contract.contractAt(number): Scroll offset in px at which the bar contracts. The default assumes a hero one screen tall.scrollTarget(HTMLElement | null): What the bar measures its scroll against. Pass a scroller when the page scrolls inside an app shell rather than the document, or the bar never learns it has passed the hero.pill(boolean): The travelling pill that rests on the current page and follows the pointer across the nav.breakpoint('sm' | 'md' | 'lg' | 'xl'): Bar width below which the links collapse into the menu button and its panel: sm 40rem, md 48rem, lg 64rem, xl 80rem. A container query on the bar, so a bar beside a sidebar switches when it runs out of room, not the window.blur(boolean): Backdrop blur behind the capsule. Turn it off if the paint cost shows.