Skip to content
Navigation Core Stable

Navbar

.md

A horizontal top-of-page bar with a brand mark, navigation links, and actions on the right.

Available for Svelte 5, React, and Vue 3.

Preview

Installation

pnpm add fancy-ui-svelte
import { Navbar } from "fancy-ui-svelte";

Usage

svelte
<script lang="ts">
	import { Navbar, NavbarLink } from "fancy-ui-svelte";

	let current = $state("docs");
</script>

<Navbar>
	{#snippet brand()}
		<span
			class="h-2 w-2 rounded-sm bg-gradient-to-br from-purple-500 to-cyan-400"
			aria-hidden="true"
		></span>
		FancyUI
	{/snippet}

	<NavbarLink sound href="#docs" current={current === "docs"} onclick={() => (current = "docs")}>
		Docs
	</NavbarLink>
	<NavbarLink
		sound
		href="#components"
		current={current === "components"}
		onclick={() => (current = "components")}
	>
		Components
	</NavbarLink>
	<NavbarLink
		sound
		href="#showcase"
		current={current === "showcase"}
		onclick={() => (current = "showcase")}
	>
		Showcase
	</NavbarLink>
</Navbar>

Examples

Basic Usage

With Actions

Search and a sign-in button on the right.

Sticky Bar

Pinned to the top of a scrolling container with a blurred background.

Props

PropTypeDefaultDescription
label string"Main"Accessible name for the nav landmark.
sticky booleanfalsePins the bar to the top with `position: sticky` and a translucent, blurred background.
bordered booleantrueDraws a 1px hairline along the bottom edge.
class string-Additional CSS classes, merged onto the root.
ref HTMLElement | nullnullBindable reference to the root nav element.
NavbarLink.href *string-Destination URL.
NavbarLink.current booleanfalseMarks this as the current page — aria-current="page" plus a visible weight/colour change.
NavbarLink.external booleanfalseOpens in a new tab with a safe rel, and notes it for assistive tech.
NavbarLink.disabled booleanfalseStrips the link out of the click and keyboard-activation paths.
NavbarLink.onclick (event: MouseEvent) => void-Native click handler. Never called while disabled.
NavbarLink.class string-Additional CSS classes, merged onto the anchor.
NavbarLink.ref HTMLAnchorElement | nullnullBindable reference to the anchor element.
NavbarLink.sound booleanfalsePlays select when a navbar link that is not already current is activated, once the user has enabled sound

Slots

SlotDescription
brand The brand mark / wordmark, on the left.
children The navigation links, between the brand and the actions.
actions Actions on the right — search, sign-in, a theme switch.
NavbarLink.children The link's label.