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. How it worksHere’s what you need to know before getting started with the navbar:
Read on for an example and list of supported sub-components. Supported contentNavbars come with built-in support for a handful of sub-components. Choose from the following as needed:
Here’s an example of all the sub-components included in a responsive light-themed navbar that automatically collapses at the 5 (large) breakpoint.
This example uses color ( 6) and spacing ( 7, 8, 9, 0) utility classes.BrandThe 9 can be applied to most elements, but an anchor works best as some elements might require utility classes or custom styles.
Adding images to the 9 will likely always require custom styles or utilities to properly size. Here are some examples to demonstrate.
Navbar navigation links build on our 3 options with their own modifier class and require the use of for proper responsive styling. Navigation in navbars will also grow to occupy as much horizontal space as possible to keep your navbar contents securely aligned.Active states—with 4—to indicate the current page can be applied directly to 5s or their immediate parent 6s.
And because we use classes for our navs, you can avoid the list-based approach entirely if you like.
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 6 and 5 as shown below.
FormsPlace various form controls and components within a navbar with 2.
Align the contents of your inline forms with utilities as needed.
Input groups work, too:
Various buttons are supported as part of these navbar forms, too. This is also a great reminder that vertical alignment utilities can be used to align different sized elements. 0TextNavbars may contain bits of text with the help of 3. This class adjusts vertical alignment and horizontal spacing for strings of text. 1Mix and match with other components and utilities as needed. 2Color schemesTheming the navbar has never been easier thanks to the combination of theming classes and 1 utilities. Choose from 2 for use with light background colors, or 3 for dark background colors. Then, customize with 4 utilities. 3ContainersAlthough it’s not required, you can wrap a navbar in a 5 to center it on a page or add one within to only center the contents of a . 4When the container is within your navbar, its horizontal padding is removed at breakpoints lower than your specified 5 class. This ensures we’re not doubling up on padding unnecessarily on lower viewports when your navbar is collapsed. 5PlacementUse 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 7, meaning they’re pulled from the normal flow of the DOM and may require custom CSS (e.g., 8 on the ) to prevent overlap with other elements.Also note that 9 uses 0, which . 6 7 8 9Responsive behaviorsNavbars can utilize 1, 2, and 5 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.For navbars that never collapse, add the 4 class on the navbar. For navbars that always collapse, don’t add any 4 class.TogglerNavbar togglers are left-aligned by default, but should they follow a sibling element like a 9, they’ll automatically be aligned to the far right. Reversing your markup will reverse the placement of the toggler. Below are examples of different toggle styles.With no 9 shown in lowest breakpoint: 0With a brand name shown on the left and toggler on the right: 1With a toggler on the left and brand name on the right: 2External contentSometimes you want to use the collapse plugin to trigger hidden content elsewhere on the page. Because our plugin works on the 8 and 9 matching, that’s easily done! |