Navbar

Documentation and examples for Bootstrap’s powerful, responsive navigation header, the navbar. Includes support for branding, navigation, and more, including support for our collapse plugin.

View the official docs here

Examples

Basic

<Navbar.Items> is a helper component which iterates over an array of NavbarItemType objects and generates the required elements. Alternatively see the manual implementation lower down.

Astro file
---
import { Navbar } from 'astro-bootstrap';
import type { NavbarItemType } from 'astro-bootstrap';
// demonstration data
const siteTitle = 'Astro site'; // pull this in from a config file
const items: NavbarItemType[] = [
  // pull this in from a config file
  { text: 'Home', href: '#' },
  { text: 'About', href: '#' },
  {
    text: 'Dropdown',
    subItems: [
      { text: 'First child', href: '#' },
      { divider: true },
      { text: 'Second child', href: '#' },
    ],
  },
];

const id = 'navbarDemo';
---

<Navbar class="navbar-expand-lg bg-primary" data-bs-theme="dark">
  <div class="container-fluid">
    <a class="navbar-brand" href="#">{siteTitle}</a>
    <Navbar.Toggler controls={id} />
    <Navbar.Collapse {id}>
      <Navbar.Items {items} class="me-auto mb-2 mb-lg-0" />
    </Navbar.Collapse>
  </div>
</Navbar>

API

import { Navbar } from 'astro-bootstrap'
NameTypeDefaultDescription
controls required string Must be the same as the id property of the &lt;Navbar.Collapse /&gt; component.
import { Navbar } from 'astro-bootstrap'
NameTypeDefaultDescription
id required string Must be the same as the contols property of the &lt;Navbar.Toggler /&gt; component.
import { Navbar } from 'astro-bootstrap'
NameTypeDefaultDescription
title required string Set the innerText for the dropdown menu item.
children required array of objects See below for object properties