Floating pill navbar
A pill that floats above the page: the active-link indicator springs across, and the moment you scroll the buttons tighten and the wordmark folds away to hand the room to the content — all inside a stage with real inner scrolling.
Real scenarios
The component as it is used in a product — not a specimen grid.
A pill that floats, slides and folds
Scroll the stage: past 24px the pill condenses — tighter padding, deeper shadow, the wordmark folding away — while the indicator keeps springing across the links. Sticky, never fixed.
Release intelligence for global product teams
Traces, releases and alerts in one workspace — from the first commit in Frankfurt to the last rollout in Singapore.
Meridian — SOC 2 Type II · GDPR · deployed in 12 regions
Resting versus condensed
The same pill at both ends of the scroll — hover the condensed one and it still works at full size.
Important props
| Prop | Type | Default | What it does |
|---|---|---|---|
| sticky-offset | length | '12px' | How far the pill rides from the stage’s top edge when stuck; sticky is allowed, fixed never. |
| indicator | motion | 'slide · 260ms' | The indicator pill glides by measuring the real active link; correct in both directions. |
| condensed-at | px | '24' | The inner-scroll threshold in px that condenses the pill: padding, gaps and shadow. |
| radius | length | '999px' | The full-pill rounding; the signature of modern floating navbars. |
Snippet
{{-- resources/views/components/floating-pill.blade.php — the pill over any page --}}
<div class="fpn" x-data="{
tab: 'product', shrunk: false,
place(el) {
this.$refs.links.style.setProperty('--fpn-x', el.offsetLeft + 'px');
this.$refs.links.style.setProperty('--fpn-w', el.offsetWidth + 'px');
},
}">
<div class="fpn-scroll" x-on:scroll.passive="shrunk = $event.target.scrollTop > 24">
<nav class="fpn-nav" x-bind:data-shrunk="shrunk" aria-label="Primary">
<b class="fpn-brand"><i aria-hidden="true"></i><span class="fpn-word">Meridian</span></b>
<div class="fpn-links" x-ref="links"
x-init="$nextTick(() => place($refs.links.querySelector('[aria-current]')))"
x-on:resize.window="place($refs.links.querySelector('[aria-current]'))">
<span class="fpn-ind" aria-hidden="true"></span>
<button type="button" x-bind:aria-current="tab === 'product' ? 'page' : null"
x-on:click="tab = 'product'; place($el)">Product</button>
<button type="button" x-bind:aria-current="tab === 'solutions' ? 'page' : null"
x-on:click="tab = 'solutions'; place($el)">Solutions</button>
<button type="button" x-bind:aria-current="tab === 'pricing' ? 'page' : null"
x-on:click="tab = 'pricing'; place($el)">Pricing</button>
</div>
<a class="fpn-cta" href="#start">Start free</a>
</nav>
<header class="fpn-hero">…page content under the pill…</header>
</div>
</div>
<style>
.fpn-scroll { block-size: 30rem; overflow-y: auto; }
.fpn-nav { position: sticky; inset-block-start: .75rem; z-index: 5; display: flex; align-items: center;
gap: .5rem; margin-inline: auto; inline-size: fit-content; padding: .5rem .5rem .5rem 1rem;
border-radius: 999px; background: #fff; box-shadow: 0 10px 30px #1118271a;
transition: padding .25s, box-shadow .25s; }
.fpn-nav[data-shrunk='true'] { padding-block: .25rem; box-shadow: 0 6px 16px #11182726; }
.fpn-links { position: relative; display: flex; gap: .25rem; }
/* physical on purpose: it pairs with the offsetLeft measurement, right in both directions */
.fpn-ind { position: absolute; inset-block: 0; left: var(--fpn-x, 0); inline-size: var(--fpn-w, 0);
border-radius: 999px; background: #eef2ff; transition: left .26s cubic-bezier(.2,0,0,1), inline-size .26s; }
.fpn-links button { position: relative; padding: .45rem .9rem; border: 0; background: none; cursor: pointer; }
.fpn-word { max-inline-size: 6rem; transition: max-inline-size .3s; overflow: clip; white-space: nowrap; }
.fpn-nav[data-shrunk='true'] .fpn-word { max-inline-size: 0; }
</style>
// app/Pages/Marketing.jsx — Inertia (React) page; renders the React
// snippet below unchanged, with Inertia's Link wired into the provider.
import { Link } from '@inertiajs/react';
import { NabuXUIProvider } from '@nabuxai/ui-react';
import FloatingPillNav from '@/components/FloatingPillNav';
export default function Marketing() {
return (
<NabuXUIProvider locale="en" linkComponent={Link}>
<FloatingPillNav />
</NabuXUIProvider>
);
}
// FloatingPillNav.jsx — the pill that floats over the page and condenses on scroll
import { useEffect, useRef, useState } from 'react';
import '@nabuxai/ui-core/css';
const LINKS = [
{ id: 'product', label: 'Product' },
{ id: 'solutions', label: 'Solutions' },
{ id: 'pricing', label: 'Pricing' },
{ id: 'docs', label: 'Docs' },
];
export default function FloatingPillNav() {
const [tab, setTab] = useState('product');
const [shrunk, setShrunk] = useState(false);
const [ind, setInd] = useState({ x: 0, w: 0 });
const scrollRef = useRef(null);
const linkRefs = useRef({});
// Measure the active link — physical left/width, correct in LTR and RTL alike.
const place = (id) => {
const el = linkRefs.current[id];
if (el) setInd({ x: el.offsetLeft, w: el.offsetWidth });
};
useEffect(() => { place(tab); }, [tab]);
useEffect(() => {
const onResize = () => place(tab);
window.addEventListener('resize', onResize);
return () => window.removeEventListener('resize', onResize);
}, [tab]);
return (
<>
<style>{`
.fpn-scroll { block-size: 30rem; overflow-y: auto; border-radius: 1rem;
background: linear-gradient(180deg, #eef2ff, #f8fafc 60%); }
.fpn-nav { position: sticky; inset-block-start: .75rem; z-index: 5; display: flex; align-items: center;
gap: .5rem; margin-inline: auto; inline-size: fit-content; padding: .5rem .5rem .5rem 1rem;
border-radius: 999px; background: #fff; box-shadow: 0 10px 30px #1118271a;
transition: padding .25s, box-shadow .25s; font: 500 14px/1 Inter, sans-serif; }
.fpn-nav[data-shrunk='true'] { padding-block: .25rem; box-shadow: 0 6px 16px #11182726; }
.fpn-brand { display: flex; align-items: center; gap: .5rem; }
.fpn-brand i { inline-size: 1.25rem; aspect-ratio: 1; border-radius: 50%;
background: linear-gradient(135deg, #6366f1, #d946ef); }
.fpn-word { max-inline-size: 6rem; transition: max-inline-size .3s; overflow: clip; white-space: nowrap; }
.fpn-nav[data-shrunk='true'] .fpn-word { max-inline-size: 0; }
.fpn-links { position: relative; display: flex; gap: .25rem; }
.fpn-ind { position: absolute; inset-block: 0; left: var(--fpn-x); inline-size: var(--fpn-w);
border-radius: 999px; background: #eef2ff;
transition: left .26s cubic-bezier(.2,0,0,1), inline-size .26s; }
.fpn-links button { position: relative; padding: .45rem .9rem; border: 0; background: none; cursor: pointer; }
.fpn-cta { padding: .5rem 1rem; border-radius: 999px; background: #4f46e5; color: #fff; text-decoration: none; }
`}</style>
<div
className="fpn-scroll"
ref={scrollRef}
onScroll={(e) => setShrunk(e.currentTarget.scrollTop > 24)}
>
<nav className="fpn-nav" data-shrunk={shrunk} aria-label="Primary">
<b className="fpn-brand"><i aria-hidden="true"></i><span className="fpn-word">Meridian</span></b>
<div className="fpn-links" style={{ '--fpn-x': `${ind.x}px`, '--fpn-w': `${ind.w}px` }}>
<span className="fpn-ind" aria-hidden="true" />
{LINKS.map((l) => (
<button
key={l.id}
type="button"
aria-current={tab === l.id ? 'page' : null}
ref={(el) => { linkRefs.current[l.id] = el; }}
onClick={() => setTab(l.id)}
>
{l.label}
</button>
))}
</div>
<a className="fpn-cta" href="#start">Start free</a>
</nav>
<header className="fpn-hero" style={{ padding: '9rem 1.5rem 4rem', textAlign: 'center' }}>
<h1>Release intelligence for global teams</h1>
<p>Traces, releases and alerts — one workspace from Frankfurt to Singapore.</p>
</header>
</div>
</>
);
}
<!-- FloatingPillNav.vue — the pill that floats over the page and condenses on scroll -->
<script setup lang="ts">
import { nextTick, onBeforeUnmount, onMounted, ref } from 'vue';
import '@nabuxai/ui-core/css';
const LINKS = [
{ id: 'product', label: 'Product' },
{ id: 'solutions', label: 'Solutions' },
{ id: 'pricing', label: 'Pricing' },
{ id: 'docs', label: 'Docs' },
];
const tab = ref('product');
const shrunk = ref(false);
const linksEl = ref<HTMLElement | null>(null);
const ind = ref({ x: 0, w: 0 });
// Measure the active link — physical left/width, correct in LTR and RTL alike.
function place(id: string) {
const el = linksEl.value?.querySelector<HTMLElement>(`[data-id="${id}"]`);
if (el) ind.value = { x: el.offsetLeft, w: el.offsetWidth };
}
function pick(id: string) { tab.value = id; nextTick(() => place(id)); }
function onScroll(e: Event) { shrunk.value = (e.target as HTMLElement).scrollTop > 24; }
const onResize = () => place(tab.value);
onMounted(() => { nextTick(() => place(tab.value)); window.addEventListener('resize', onResize); });
onBeforeUnmount(() => window.removeEventListener('resize', onResize));
</script>
<template>
<div class="fpn-scroll" @scroll.passive="onScroll">
<nav class="fpn-nav" :data-shrunk="shrunk" aria-label="Primary">
<b class="fpn-brand"><i aria-hidden="true"></i><span class="fpn-word">Meridian</span></b>
<div class="fpn-links" ref="linksEl" :style="{ '--fpn-x': ind.x + 'px', '--fpn-w': ind.w + 'px' }">
<span class="fpn-ind" aria-hidden="true"></span>
<button v-for="l in LINKS" :key="l.id" type="button" :data-id="l.id"
:aria-current="tab === l.id ? 'page' : null" @click="pick(l.id)">
{{ l.label }}
</button>
</div>
<a class="fpn-cta" href="#start">Start free</a>
</nav>
<header class="fpn-hero">
<h1>Release intelligence for global teams</h1>
<p>Traces, releases and alerts — one workspace from Frankfurt to Singapore.</p>
</header>
</div>
</template>
<style scoped>
.fpn-scroll { block-size: 30rem; overflow-y: auto; border-radius: 1rem;
background: linear-gradient(180deg, #eef2ff, #f8fafc 60%); }
.fpn-nav { position: sticky; inset-block-start: .75rem; z-index: 5; display: flex; align-items: center;
gap: .5rem; margin-inline: auto; inline-size: fit-content; padding: .5rem .5rem .5rem 1rem;
border-radius: 999px; background: #fff; box-shadow: 0 10px 30px #1118271a;
transition: padding .25s, box-shadow .25s; font: 500 14px/1 Inter, sans-serif; }
.fpn-nav[data-shrunk='true'] { padding-block: .25rem; box-shadow: 0 6px 16px #11182726; }
.fpn-brand { display: flex; align-items: center; gap: .5rem; }
.fpn-brand i { inline-size: 1.25rem; aspect-ratio: 1; border-radius: 50%;
background: linear-gradient(135deg, #6366f1, #d946ef); }
.fpn-word { max-inline-size: 6rem; transition: max-inline-size .3s; overflow: clip; white-space: nowrap; }
.fpn-nav[data-shrunk='true'] .fpn-word { max-inline-size: 0; }
.fpn-links { position: relative; display: flex; gap: .25rem; }
.fpn-ind { position: absolute; inset-block: 0; left: var(--fpn-x); inline-size: var(--fpn-w);
border-radius: 999px; background: #eef2ff;
transition: left .26s cubic-bezier(.2,0,0,1), inline-size .26s; }
.fpn-links button { position: relative; padding: .45rem .9rem; border: 0; background: none; cursor: pointer; }
.fpn-cta { padding: .5rem 1rem; border-radius: 999px; background: #4f46e5; color: #fff; text-decoration: none; }
.fpn-hero { padding: 9rem 1.5rem 4rem; text-align: center; }
</style>
<!-- FloatingPillNav.svelte — the pill that floats over the page and condenses on scroll -->
<script lang="ts">
import '@nabuxai/ui-core/css';
const LINKS = [
{ id: 'product', label: 'Product' },
{ id: 'solutions', label: 'Solutions' },
{ id: 'pricing', label: 'Pricing' },
{ id: 'docs', label: 'Docs' },
];
let tab = $state('product');
let shrunk = $state(false);
let linksEl = $state<HTMLElement | null>(null);
let ind = $state({ x: 0, w: 0 });
// Measure the active link — physical left/width, correct in LTR and RTL alike.
function place(id: string) {
const el = linksEl?.querySelector<HTMLElement>(`[data-id="${id}"]`);
if (el) ind = { x: el.offsetLeft, w: el.offsetWidth };
}
function pick(id: string) { tab = id; requestAnimationFrame(() => place(id)); }
function onScroll(e: Event) { shrunk = (e.target as HTMLElement).scrollTop > 24; }
$effect(() => { linksEl; requestAnimationFrame(() => place(tab)); });
</script>
<div class="fpn-scroll" @scroll.passive={onScroll}>
<nav class="fpn-nav" data-shrunk={shrunk} aria-label="Primary">
<b class="fpn-brand"><i aria-hidden="true"></i><span class="fpn-word">Meridian</span></b>
<div class="fpn-links" bind:this={linksEl} style={`--fpn-x: ${ind.x}px; --fpn-w: ${ind.w}px`}>
<span class="fpn-ind" aria-hidden="true"></span>
{#each LINKS as l (l.id)}
<button type="button" data-id={l.id} aria-current={tab === l.id ? 'page' : null}
onclick={() => pick(l.id)}>
{l.label}
</button>
{/each}
</div>
<a class="fpn-cta" href="#start">Start free</a>
</nav>
<header class="fpn-hero">
<h1>Release intelligence for global teams</h1>
<p>Traces, releases and alerts — one workspace from Frankfurt to Singapore.</p>
</header>
</div>
<style>
.fpn-scroll { block-size: 30rem; overflow-y: auto; border-radius: 1rem;
background: linear-gradient(180deg, #eef2ff, #f8fafc 60%); }
.fpn-nav { position: sticky; inset-block-start: .75rem; z-index: 5; display: flex; align-items: center;
gap: .5rem; margin-inline: auto; inline-size: fit-content; padding: .5rem .5rem .5rem 1rem;
border-radius: 999px; background: #fff; box-shadow: 0 10px 30px #1118271a;
transition: padding .25s, box-shadow .25s; font: 500 14px/1 Inter, sans-serif; }
.fpn-nav[data-shrunk='true'] { padding-block: .25rem; box-shadow: 0 6px 16px #11182726; }
.fpn-brand { display: flex; align-items: center; gap: .5rem; }
.fpn-brand i { inline-size: 1.25rem; aspect-ratio: 1; border-radius: 50%;
background: linear-gradient(135deg, #6366f1, #d946ef); }
.fpn-word { max-inline-size: 6rem; transition: max-inline-size .3s; overflow: clip; white-space: nowrap; }
.fpn-nav[data-shrunk='true'] .fpn-word { max-inline-size: 0; }
.fpn-links { position: relative; display: flex; gap: .25rem; }
.fpn-ind { position: absolute; inset-block: 0; left: var(--fpn-x); inline-size: var(--fpn-w);
border-radius: 999px; background: #eef2ff;
transition: left .26s cubic-bezier(.2,0,0,1), inline-size .26s; }
.fpn-links button { position: relative; padding: .45rem .9rem; border: 0; background: none; cursor: pointer; }
.fpn-cta { padding: .5rem 1rem; border-radius: 999px; background: #4f46e5; color: #fff; text-decoration: none; }
.fpn-hero { padding: 9rem 1.5rem 4rem; text-align: center; }
</style>