Skip to content
  • No data uploaded
  • Instant results

Bootstrap 5 Navbar for React

A production-ready minimal 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 React code update instantly in your browser.

Live component editor

Library
Framework
Style
Theme
Corner radius
Live preview
import 'bootstrap/dist/css/bootstrap.min.css';
import './theme.css';
import { useState } from 'react';

export default function Navbar() {
  const [menu, setMenu] = useState(false);

  return (
    <header className="sticky-top top-0 z-1 bg-body border shadow-sm">
      <nav className="mw-6xl mx-auto px-4 py-2 d-flex align-items-center justify-content-between gap-4" aria-label="Main">
        <a href="#" className="d-flex align-items-center gap-2 fs-5 fw-bold text-decoration-none text-body-emphasis">
          <span className="badge rounded-pill bg-brand-subtle text-brand">◆</span> Acme
        </a>
        <div className="d-none d-md-flex align-items-center gap-4">
          <a href="#" className="small fw-medium text-decoration-none text-body">Product</a>
          <a href="#" className="small fw-medium text-decoration-none text-body">Solutions</a>
          <a href="#" className="small fw-medium text-decoration-none text-body">Pricing</a>
          <a href="#" className="small fw-medium text-decoration-none text-body">Docs</a>
        </div>
        <div className="d-none d-md-flex align-items-center gap-2">
          <a href="#" className="btn btn-link link-body-emphasis text-decoration-none fw-semibold rounded-2">Sign in</a>
          <a href="#" className="btn btn-brand fw-semibold rounded-2">Get started</a>
        </div>
        <button type="button" className="btn btn-link link-body-emphasis text-decoration-none fw-semibold rounded-2 d-md-none" aria-controls="mobile-menu" aria-label="Toggle menu" onClick={() => setMenu((v) => !v)}>☰</button>
      </nav>
      <div id="mobile-menu" hidden={!menu}>
        <div className="d-md-none px-4 pb-3 d-flex flex-column gap-1">
          <a href="#" className="btn btn-link link-body-emphasis text-decoration-none fw-semibold rounded-2">Product</a>
          <a href="#" className="btn btn-link link-body-emphasis text-decoration-none fw-semibold rounded-2">Solutions</a>
          <a href="#" className="btn btn-link link-body-emphasis text-decoration-none fw-semibold rounded-2">Pricing</a>
          <a href="#" className="btn btn-link link-body-emphasis text-decoration-none fw-semibold rounded-2">Docs</a>
          <a href="#" className="btn btn-brand fw-semibold rounded-2 mt-2">Get started</a>
        </div>
      </div>
    </header>
  );
}
All components →

Free Bootstrap 5 Navbar for React by pGento

Install Bootstrap 5 for React

Create a React project with Vite and install Bootstrap:

npm create vite@latest my-app -- --template react
cd my-app
npm install
npm install bootstrap

Save the generated theme.css next to the component; the component file already imports bootstrap/dist/css/bootstrap.min.css and ./theme.css. No Bootstrap JavaScript is required — interactivity uses useState.

Use the navbar in React

// App.jsx
import Navbar from './Navbar';

export default function App() {
  return <Navbar />;
}

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 Bootstrap classes plus a tiny CSS-variable theme file, so the copied code has no runtime dependency on this site.

Compatibility

ItemDetails
CSS frameworkBootstrap 5.3+ (CSS only)
LibraryReact 18+ (function component)
Interactive statemenu
Dark modeYes — toggle in the editor
StyleMinimal

Frequently asked questions

How do I install this Bootstrap navbar in React?
Create a React project, install Bootstrap 5 as shown in the installation section, then paste the generated code. Also save the generated theme.css file.
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.
Bootstrap 5 Navbar for React

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.