Skip to content
Blocks

Floating Navigation

A complete floating navigation section, ready to adapt to your product.

Open ↗

Make it yours.

Install the editable source and its dependencies into your React + Tailwind project.

Scroll horizontally for long lines
pnpm dlx shadcn@4.0.8 add http://localhost:3000/r/floating-navigation.json

Use it

Scroll horizontally for long lines
"use client";
import {FloatingNavigation} from '@/components/jez-ui/blocks/floating-navigation';

export default function Example(){

return <><FloatingNavigation/></>;
}

Props & types

Scroll horizontally for long lines
{
  className?: string;
  items?: { label: string; href: string; icon: typeof Home }[];
  currentHref?: string;
}

Source

View 2 source files

registry/blocks/floating-navigation.tsx

Scroll horizontally for long lines
"use client";
import * as React from "react";
import { Home, Layers, Bookmark, Settings } from "lucide-react";
import { motion, useReducedMotion } from "motion/react";
import { cn } from "../ui/utils";
export function FloatingNavigation({
  className,
  items = [
    { label: "Home", href: "/", icon: Home },
    { label: "Components", href: "/components", icon: Layers },
    { label: "Blocks", href: "/blocks", icon: Bookmark },
    { label: "Templates", href: "/templates", icon: Settings },
  ],
  currentHref = "/",
}: {
  className?: string;
  items?: { label: string; href: string; icon: typeof Home }[];
  currentHref?: string;
}) {
  const reduced = useReducedMotion();
  const id = React.useId();
  return (
    <nav
      aria-label="Quick navigation"
      className={cn(
        "mx-auto flex w-fit max-w-full items-center gap-1 rounded-2xl border border-border bg-background/95 p-1.5 shadow-lg backdrop-blur-lg",
        className,
      )}
    >
      {items.map((item) => (
        <a
          key={item.href}
          href={item.href}
          aria-current={currentHref === item.href ? "page" : undefined}
          className="relative flex min-w-0 items-center gap-2 rounded-xl px-3 py-3 text-sm sm:px-4"
        >
          {currentHref === item.href && (
            <motion.span
              layoutId={id}
              transition={
                reduced
                  ? { duration: 0 }
                  : { type: "spring", stiffness: 400, damping: 35 }
              }
              className="absolute inset-0 rounded-xl bg-primary/8"
            />
          )}
          <item.icon
            size={18}
            className={cn(
              "relative shrink-0",
              currentHref === item.href
                ? "text-primary"
                : "text-muted-foreground",
            )}
          />
          <span
            className={cn(
              "relative",
              currentHref === item.href
                ? "font-medium text-primary"
                : "sr-only sm:not-sr-only sm:text-muted-foreground",
            )}
          >
            {item.label}
          </span>
        </a>
      ))}
    </nav>
  );
}

registry/ui/utils.ts

Scroll horizontally for long lines
import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...values: ClassValue[]) {
  return twMerge(clsx(values));
}

Dependencies

lucide-react@0.577.0 · motion@13.2.0 · clsx@2.1.1 · tailwind-merge@3.5.0

Accessibility & behaviour

Provide meaningful labels and preserve keyboard focus styles. Check contrast when customising theme colours.

Read the accessibility and performance guide →