---
title: Navbars
summary: A navbar is the horizontal bar at the top of the page with the logo, the main links and controls such as search or a user menu.
description: Responsive navigation bars, with the markup, the variants and a language selector.
related: [/ui/layout/page-layouts, /ui/components/dropdown]
sass-vars: navbar
---
import Example from '@components/Example.astro'
import Logo from '@shared/components/navbar/Logo.astro'
import Icon from '@ui/Icon.astro'
A navbar is the horizontal bar at the top of the page. It holds the logo, the main links and often a search field, [buttons](/ui/components/button) or [dropdown menus](/ui/components/dropdown) such as a user menu.
On small screens the links collapse behind a toggle button, and the same markup works in the light and the dark color mode.
## Sample navbar
Start with the `.navbar` class on a `header` element. `navbar-expand-md` sets the breakpoint at which the collapsed menu turns into a row of links, and `d-print-none` hides the bar when the page is printed.
```html
```
Inside it, a `container-xl` keeps the content aligned with the page. The full markup with the brand, the toggler, the links and a user menu looks like this:
## Floating navbar
Add `navbar-floating` to keep a gap between the navbar and the edges around it. The navbar gets a border on every side and rounded corners. It floats only from its `navbar-expand-*` breakpoint up. Below the breakpoint it stays attached to the edges, like a regular navbar.
...`}>
The class works on the vertical sidebar too. The sidebar keeps its width, also when it is folded, and the page content next to it moves over by the same gap.
```html
```
The gap is `0.5rem` by default. Change it with `$navbar-floating-margin` in SCSS.
To float the navigation of the whole page without touching the markup, set [`data-bs-navbar-style="floating"`](/ui/layout/page-layouts#floating-navigation) on ``.
## Language selector
Add a language selector to the navbar as a dropdown. The toggle shows the current language code and the menu lists the languages with a `data-lang` attribute, so a script can switch the locale. Give the toggle an `aria-label`, because the code alone does not say what the control does.
The preview navbar renders it from `shared/data/languages.json` with the `showLanguageSelector` prop of `NavbarSide`.
## Accessibility
- Wrap each navigation region in `nav` and give it an `aria-label`, so a sidebar and a top bar can be told apart.
- The toggler needs `aria-controls` pointing at the collapsing element and a label such as "Toggle navigation". Bootstrap manages `aria-expanded`.
- Mark the current page with `aria-current="page"`.
- The brand link should say where it goes. A logo alone needs an `aria-label` or `visually-hidden` text.
- A dropdown in the navbar follows the [dropdown](/ui/components/dropdown) rules - the trigger is a `button` or a link with an `href`.