Skip to content
  • No data uploaded
  • Instant results

Tailwind CSS Navbar for Vanilla JS — Glassmorphism

A production-ready glassmorphism navbar: a responsive top navigation bar with a logo, primary links, a sign-in/CTA pair on desktop and a collapsible hamburger menu on mobile. Pick your brand color, toggle dark mode and corner radius — the live preview and the Vanilla JS code update instantly in your browser.

Live component editor

Library
Framework
Style
Theme
Corner radius
Live preview
<!-- Requires Tailwind CSS v3 (CLI/PostCSS build, or the Play CDN for prototypes) -->
<header class="sticky top-0 z-10 bg-white/60 backdrop-blur-xl border border-white/60 shadow-2xl">
  <nav class="max-w-6xl mx-auto px-6 py-3 flex items-center justify-between gap-6" aria-label="Main">
    <a href="#" class="flex items-center gap-2 text-lg font-bold no-underline text-slate-900">
      <span class="inline-flex items-center px-2.5 py-0.5 text-xs font-semibold rounded-full bg-[#4f46e5]/10 text-[#4f46e5]">◆</span> Acme
    </a>
    <div class="hidden md:flex items-center gap-6">
      <a href="#" class="text-sm font-medium no-underline text-slate-700">Product</a>
      <a href="#" class="text-sm font-medium no-underline text-slate-700">Solutions</a>
      <a href="#" class="text-sm font-medium no-underline text-slate-700">Pricing</a>
      <a href="#" class="text-sm font-medium no-underline text-slate-700">Docs</a>
    </div>
    <div class="hidden md:flex items-center gap-2">
      <a href="#" class="inline-flex items-center justify-center px-3 py-2 text-sm font-semibold rounded-lg transition-colors text-slate-700 hover:bg-slate-900/5">Sign in</a>
      <a href="#" class="inline-flex items-center justify-center px-4 py-2.5 text-sm font-semibold rounded-lg bg-[#4f46e5] hover:bg-[#433cc3] text-white shadow-sm transition-colors focus:outline-none focus:ring-2 focus:ring-[#4f46e5] focus:ring-offset-2 focus:ring-offset-white">Get started</a>
    </div>
    <button type="button" class="inline-flex items-center justify-center px-3 py-2 text-sm font-semibold rounded-lg transition-colors text-slate-700 hover:bg-slate-900/5 md:hidden" aria-controls="mobile-menu" aria-label="Toggle menu" data-toggle="menu">☰</button>
  </nav>
  <div id="mobile-menu" data-show="menu" hidden>
    <div class="md:hidden px-6 pb-4 flex flex-col gap-1">
      <a href="#" class="inline-flex items-center justify-center px-3 py-2 text-sm font-semibold rounded-lg transition-colors text-slate-700 hover:bg-slate-900/5">Product</a>
      <a href="#" class="inline-flex items-center justify-center px-3 py-2 text-sm font-semibold rounded-lg transition-colors text-slate-700 hover:bg-slate-900/5">Solutions</a>
      <a href="#" class="inline-flex items-center justify-center px-3 py-2 text-sm font-semibold rounded-lg transition-colors text-slate-700 hover:bg-slate-900/5">Pricing</a>
      <a href="#" class="inline-flex items-center justify-center px-3 py-2 text-sm font-semibold rounded-lg transition-colors text-slate-700 hover:bg-slate-900/5">Docs</a>
      <a href="#" class="inline-flex items-center justify-center px-4 py-2.5 text-sm font-semibold rounded-lg bg-[#4f46e5] hover:bg-[#433cc3] text-white shadow-sm transition-colors focus:outline-none focus:ring-2 focus:ring-[#4f46e5] focus:ring-offset-2 focus:ring-offset-white mt-2">Get started</a>
    </div>
  </div>
</header>

<script>
  (() => {
    const state = { menu: false };
    const actions = {  };
    const pair = (s) => s.split(':');
    const sync = () => {
      document.querySelectorAll('[data-show]').forEach((el) => (el.hidden = !state[el.dataset.show]));
      document.querySelectorAll('[data-hide]').forEach((el) => (el.hidden = !!state[el.dataset.hide]));
      document.querySelectorAll('[data-when]').forEach((el) => { const [k, v] = pair(el.dataset.when); el.hidden = state[k] !== v; });
      document.querySelectorAll('[data-pressed]').forEach((el) => { const [k, v] = pair(el.dataset.pressed); el.setAttribute('aria-pressed', String(state[k] === v)); });
      document.querySelectorAll('[data-expanded]').forEach((el) => el.setAttribute('aria-expanded', String(!!state[el.dataset.expanded])));
    };
    document.addEventListener('click', (e) => {
      const t = e.target.closest('[data-toggle],[data-open],[data-close],[data-set],[data-call]');
      if (!t) return;
      const { toggle, open, close, set, call } = t.dataset;
      if (call) actions[call]?.(e);
      if (toggle) state[toggle] = !state[toggle];
      if (open) state[open] = true;
      if (close) state[close] = false;
      if (set) { const [k, v] = pair(set); state[k] = v; }
      sync();
    });
    sync();
  })();
</script>
All components →

Free Tailwind CSS Navbar for Vanilla JS — Glassmorphism by pGento

Install Tailwind CSS for Vanilla JS

Prototype instantly with the Play CDN, or install the Tailwind CLI for production:

<script src="https://cdn.tailwindcss.com"></script>
npm install -D tailwindcss@3
npx tailwindcss init
npx tailwindcss -i ./src/input.css -o ./dist/output.css --watch

Add ./**/*.html to content in tailwind.config.js and put the three @tailwind directives in src/input.css.

Use the navbar in Vanilla JS

Paste the markup where the component should appear. The small inline <script> wires up the interactive state with one delegated click listener — no framework needed.

Accessibility & customization

Uses a <nav> landmark with aria-label, the menu button exposes aria-controls and aria-label, and links remain real <a> elements so keyboard and screen-reader navigation work without JavaScript.

Every color, radius and dark-mode choice is baked into plain utility classes, so the copied code has no runtime dependency on this site. The glass style relies on backdrop-filter, supported in all current browsers; place it over a colorful background for the best effect.

Compatibility

ItemDetails
CSS frameworkTailwind CSS v3.4+
LibraryPlain HTML + optional vanilla JS
Interactive statemenu
Dark modeYes — toggle in the editor
StyleGlassmorphism (backdrop blur)

Frequently asked questions

How do I install this Tailwind navbar in Vanilla JS?
Create a web page, install Tailwind CSS as shown in the installation section, then paste the generated code.
Can I change the color of the navbar?
Yes. Use the brand color picker or type any hex code — the preview and code update instantly, and the color is written directly into the classes you copy.
Does the navbar support dark mode?
Yes. Toggle “Dark mode” in the editor to generate a dark palette version of the same component.
Is the navbar accessible?
Uses a <nav> landmark with aria-label, the menu button exposes aria-controls and aria-label, and links remain real <a> elements so keyboard and screen-reader navigation work without JavaScript.
Is this component free for commercial use?
Yes. The generated code is yours to use in personal and commercial projects without attribution.
Tailwind CSS Navbar for Vanilla JS — Glassmorphism

Embed this tool on your site

Paste this code into any web page. It stays free, fast and ad-free inside your site.

Print or save as PDF

Prints just this tool and its result. Choose “Save as PDF” as the printer to get a file. Branding is stored only in this browser.