# Navbars
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.
Here’s what you need to know before getting started with the navbar:
- Navbars require a wrapping
.navbar
with.navbar-expand{-sm|-md|-lg|-xl}
for responsive collapsing and color scheme classes. - Navbars and their contents are fluid by default. Use optional containers to limit their horizontal width.
- Use our spacing and flex utility classes for controlling spacing and alignment within navbars.
- Navbars are responsive by default, but you can easily modify them to change that. Responsive behavior depends on our Collapse JavaScript plugin.
- Navbars are hidden by default when printing. Force them to be printed by adding
.d-print
to the.navbar
. - Ensure accessibility by using a
<nav>
element or, if using a more generic element such as a<div>
, add arole="navigation"
to every navbar to explicitly identify it as a landmark region for users of assistive technologies. - You need a `sidebar-collapse` class on document body in order to make the navbars work properly on mobile
You don't have to worry about most of the points above because we created a custom Navbar component that is simple to use. It's good to know all the details, just in case you want to customize this component.
To use the navbar, first import it:
import {Navbar} from 'src/components'
Global usage
Vue.component(Navbar)
Local usage
export default {
components: {
Navbar
}
}
2
3
4
5
# Primary navbar
:::tip
showMenu
property applies only on small viewport (mobile). Shrink the browser to see that in action
:::
:::tip
You can change navbar color with the type
prop.
:::
Navbar with links
You may also utilize dropdowns in your navbar nav.
Dropdown menus require a wrapping element for positioning, so be sure to use separate and nested elements for
.nav-item
and .nav-link
as shown below.
# Forms
Place various form controls and components within a navbar with .form-inline.
# How to enable Burger Menu
We created for you a class named .burger-menu
and once it is applied to the tag body it will transform
the navbar like it appears on the responsive mode and when you will open it will come from the right side or left side.
To make open from left side please add the class .menu-on-left
also on the body tag.
<!doctype html>
<html lang="en">
<head>
...
</head>
<body class="burger-menu">
...
</body>
</html>
2
3
4
5
6
7
8
9
# Colored navbars
# Placement
Use our position utilities to place navbars in non-static positions.
Choose from fixed to the top, fixed to the bottom, or stickied to the top
(scrolls with the page until it reaches the top, then stays there).
Fixed navbars use position: fixed
, meaning they’re pulled from the normal flow of
the DOM and may require custom CSS (e.g., padding-top
on the <body>
) to prevent overlap with other elements.
Also note that .sticky-top
uses position: sticky
, which
isn’t fully supported in every browser.
# Responsive behaviors
Navbars can utilize .navbar-toggler
, .navbar-collapse
, and
.navbar-expand{-sm|-md|-lg|-xl}
classes to change when their content collapses behind a button.
In combination with other utilities, you can easily choose when to show or hide particular elements.
These classes can be also added with the help of expand
prop.
E.g expand="md"
For navbars that never collapse, add the .navbar-expand
class on the navbar.
For navbars that always collapse, don’t add any .navbar-expand
class.
Note that we already integrated a toggler button inside our Navbar
component so you don't have to worry
about adding it. It will simply appear on small screens.
# Navbar Props
# Navbar Slots
Name | Description |
---|---|
default | Navbar left side content (brand and toggle button ) |
navbar-menu | Content of the navbar (right on desktop, dropdown menu on mobile) |
# Navbar Toggle Button Props
← Modal Nucleo Icons →