Modus UI

Morphing Navbar

Web (React)

A premium, scroll-aware header that dynamically adjusts its layout density and logo scale based on scroll position.

A premium, scroll-aware navigation header that dynamically adjusts its layout, logo scale, and background density as the user scrolls. Part of the Premium UI series.

Scroll to Morph

This preview container simulates a real page. Scroll down to see the Navbar transition into its collapsed state, scaling the logo and hiding breadcrumbs to maximize your reading area.

Installation

CLI

npx @modus-ui/cli add morphing-navbar

Manual

  1. Copy the code from the component tab.
  2. Create a file at components/ui/morphing-navbar.tsx.
  3. Paste the code.

Usage

tsx
import { MorphingNavbar } from "@/components/ui/morphing-navbar";
import { GraduationCap } from "lucide-react";

export default function Example() {
  return (
    <MorphingNavbar
      title="Morphing Navbar"
      logo={GraduationCap}
      breadcrumbSteps={[{ label: "Components" }, { label: "Navigation" }]}
    />
  );
}

Props

PropTypeDefaultDescription
titlestring"Morphing Navbar"The title text displayed next to the logo.
logoElementTypeGraduationCapThe icon component to display as the logo.
breadcrumbStepsStep[][]Array of breadcrumb steps to display in expanded mode.
onHomeClick() => void-Called when the home button is clicked.
onProfileClick() => void-Called when the profile avatar is clicked.
onToggleSidebar() => void-Called when the sidebar toggle is clicked.
sidebarOpenbooleanfalseWhether the sidebar is open (sets the mobile toggle icon).
scrollThresholdnumber36Scroll distance in pixels before morphing to collapsed state.
targetIdstring-Optional ID of a scrollable container to track instead of the window.

Comments

  • No comments yet.