Skip to content
← UI Library

Tubelight navbar

A floating pill navigation bar whose active tab glows like a strip light and springs between links.

Svelte 5 · Version 1.0.0 · Zero extra packages

Connect MCP

Live preview

Design decision

A single moving highlight shows where you are without boxing every link. Original Svelte 5 implementation. No code was copied from the inspiring component.

Inspired by Tubelight Navbar by @ayushmxxn on 21st.dev ↗

Source and integration

Pass items with label and href. Bind active to control the current link. Map --ui-accent to your brand colour.

You may copy and adapt this original SaaSCrisp implementation in personal and commercial websites.

TubelightNav.svelte
<script lang="ts">
	type Item = { label: string; href: string };
	let {
		items,
		active = $bindable(items[0]?.label ?? ''),
		label = 'Main'
	}: { items: Item[]; active?: string; label?: string } = $props();

	let links: HTMLAnchorElement[] = $state([]);
	let indicator = $state({ x: 0, width: 0, ready: false });
	const index = $derived(Math.max(0, items.findIndex((item) => item.label === active)));

	$effect(() => {
		const link = links[index];
		if (link) indicator = { x: link.offsetLeft, width: link.offsetWidth, ready: true };
	});
</script>

<nav class="tn" aria-label={label}>
	<span
		class="tn-pill"
		class:ready={indicator.ready}
		style:transform="translateX({indicator.x}px)"
		style:width="{indicator.width}px"
		aria-hidden="true"
	>
		<span class="tn-lamp"></span>
	</span>
	{#each items as item, i (item.label)}
		<a
			bind:this={links[i]}
			href={item.href}
			aria-current={i === index ? 'page' : undefined}
			onclick={() => (active = item.label)}>{item.label}</a
		>
	{/each}
</nav>

<style>
	.tn {
		--_border: var(--ui-border, rgb(255 255 255 / 0.08));
		--_text: var(--ui-text, #ededf0);
		--_muted: var(--ui-muted, #8b8b94);
		--_accent: var(--ui-accent, #c8ff3c);
		position: relative;
		display: inline-flex;
		max-width: 100%;
		padding: 4px;
		overflow-x: auto;
		border: 1px solid var(--_border);
		border-radius: 999px;
		background: rgb(18 18 21 / 0.7);
		backdrop-filter: blur(12px);
		box-shadow:
			inset 0 1px 0 rgb(255 255 255 / 0.05),
			0 8px 30px -10px rgb(0 0 0 / 0.7);
		font-family: var(--ui-font, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif);
		scrollbar-width: none;
	}
	.tn-pill {
		position: absolute;
		inset: 4px auto 4px 0;
		border-radius: 999px;
		background: rgb(255 255 255 / 0.06);
	}
	.tn-pill.ready {
		transition:
			transform 0.4s cubic-bezier(0.3, 1.3, 0.5, 1),
			width 0.4s cubic-bezier(0.3, 1.3, 0.5, 1);
	}
	.tn-lamp {
		position: absolute;
		top: -5px;
		left: 50%;
		width: 30px;
		height: 3px;
		translate: -50% 0;
		border-radius: 0 0 4px 4px;
		background: var(--_accent);
		box-shadow:
			0 0 8px 1px var(--_accent),
			0 6px 18px 4px color-mix(in srgb, var(--_accent) 35%, transparent);
	}
	.tn-lamp::after {
		content: '';
		position: absolute;
		top: 2px;
		left: 50%;
		width: 56px;
		height: 26px;
		translate: -50% 0;
		border-radius: 50%;
		background: color-mix(in srgb, var(--_accent) 22%, transparent);
		filter: blur(10px);
	}
	a {
		position: relative;
		padding: 8px 18px;
		border-radius: 999px;
		color: var(--_muted);
		font-size: 14px;
		font-weight: 500;
		text-decoration: none;
		white-space: nowrap;
		transition: color 0.2s;
	}
	a:hover,
	a[aria-current='page'] {
		color: var(--_text);
	}
	a:focus-visible {
		outline: 2px solid var(--_accent);
		outline-offset: -2px;
	}
	@media (max-width: 480px) {
		a {
			padding: 8px 12px;
			font-size: 13px;
		}
	}
	@media (prefers-reduced-motion: reduce) {
		.tn-pill.ready {
			transition: none;
		}
	}
</style>
Agent prompt

Use the SaaSCrisp UI Library MCP at https://www.saascrisp.com/api/library/mcp. Retrieve tubelight-navbar version 1.0.0 for svelte with get_ui_asset. Preview: https://www.saascrisp.com/library/tubelight-navbar. Confirm the project's stack, reuse local primitives and map CSS variables to existing design tokens. Integrate the files and run the project's checks. Report changed files and additional dependencies.