Navbars
Overview
Navbar is a navigation component, usually displayed on top of the page and includes brand logo, navigation, notifications, user menu, language switcher and other components. By default, navbar has top fixed
position and is a direct child of <body>
container. Navbar toggler appears next to the brand logo on small screens and can be easily adjusted with display
utility classes. You can also control responsive collapsing breakpoint directly in the markup. Navbar component is responsive by default and requires .navbar
and .navbar-expand{-sm|-md|-lg|-xl}
classes. Main navigation bar also has static position, but due to the nature of the general layout, it's moved outside all scrolable containers so that it always appears to be sticked to the top.
Table below describes all navbar types and combinations available:
Option | Description |
---|---|
Type | |
Single navbar | Single navbar. Collapsible navbar, always displayed full width without spacings (except navbar component) and on top by default. Supports different navbar components and usually appears as a main navbar with branding info, user info and navigation. |
Multiple navbars | Multiple navbars have additional display options. They can be placed one after another, mixed with page header content and main content. Second sidebar is usually used as a separate component with main navigation (in horizontal navigation layout) and alternative content. |
Navbar component | Displayed as a stand-alone component: includes spacings, borders and rounded corners. Can be placed anywhere - content area, footer, header or used as a main navbar. Supports all available navbar components. |
Positioning | |
Top single | Single top navbar, usually a main navigation toolbar. |
Top multiple | Double top navbar. Can be both static or fixed, check navbar related pages. |
Bottom single | Single bottom navbar, usually a main navigation toolbar. |
Bottom multiple | Double bottom navbar. Can be both static or fixed, check navbar related pages. |
Inside content area | Content navbar. Can be placed in any container within .content container. Useful for action toolbars |
Variations | |
Fixed | Default option. Always sticked to the page top and always visible. In static layout requires additional classes in <body> tag to add top padding to the document. Refer to the table below for more information |
Static | Means navbar is scrolled out along with content. Only available in static layout and layouts #3, 4, 5 |
Hideable | Hide navbar on scroll down and display on scroll up. Animated by default and supports both top and bottom placement. Only available in static layout and layouts #3, 4, 5 |
Styling | |
Light | Light background with adapted components: navigation, links etc. Doesn't require any color classes. |
Dark | Dark background with adapted components: navigation, links etc. Requires .navbar-dark class added to the <navbar> container. |
Custom color | Custom background color. Requires .navbar-dark class and .bg-* color class added to the <navbar> container. |
Navbar markup
Navbar markup is identical in all layout variations and matches default Bootstrap's markup. The only difference is navbar placement and type. Navbar component uses flexbox model, this means almost all components are vertically centered by default. Below you'll find markup examples of different variations of navbar component.
Static navbar
By default, top and bottom navbars in content area have static
position and scroll away along with content. This use case doesn't require any additional classes for .navbar
and <body>
containers, this means navbar appearance depends on its placement: in the template top static navbar is the first direct child of .content-inner
or .content
containers. In layout 1 and 6 there's no difference between fixed and static since it's static by default, but behaves as fixed due to layout config.
<!-- Document body -->
<body>
<!-- Main navbar -->
<div class="navbar navbar-dark navbar-expand-lg navbar-static">
<div class="container-fluid">
<!-- Mobile togglers -->
<div class="d-flex d-lg-none me-2">
...
</div>
<!-- /mobile togglers -->
<!-- Navbar brand -->
<div class="navbar-brand flex-1 flex-lg-0">
...
</div>
<!-- /navbar brand -->
<!-- Left navigation (remains visible on mobile) -->
<ul class="nav">
...
</ul>
<!-- /left navigation (remains visible on mobile) -->
<!-- Collapsible navbar content -->
<div class="navbar-collapse justify-content-center flex-lg-1 order-2 order-lg-1 collapse" id="navbar-mobile">
...
</div>
<!-- /collapsible navbar content -->
<!-- Content that remains visible on mobile -->
<div class="nav justify-content-end order-1 order-lg-2">
...
</div>
<!-- /content that remains visible on mobile -->
</div>
</div>
<!-- /main navbar -->
<!-- Page content -->
<div class="page-content">
...
</div>
<!-- /page content -->
</body>
<!-- /document body -->
Top fixed navbar
Top fixed navbar markup is similar to static, the only difference is it requires .fixed-top
class added to the <navbar>
container and proper body class to add top padding. Only available in layouts 3, 4, 5 and in static layouts of layouts 1 and 6.
<!-- Document body -->
<body class="navbar-top">
<!-- Main navbar -->
<div class="navbar navbar-dark navbar-expand-lg fixed-top">
<div class="container-fluid">
<!-- Mobile togglers -->
<div class="d-flex d-lg-none me-2">
...
</div>
<!-- /mobile togglers -->
<!-- Navbar brand -->
<div class="navbar-brand flex-1 flex-lg-0">
...
</div>
<!-- /navbar brand -->
<!-- Left navigation (remains visible on mobile) -->
<ul class="nav">
...
</ul>
<!-- /left navigation (remains visible on mobile) -->
<!-- Collapsible navbar content -->
<div class="navbar-collapse justify-content-center flex-lg-1 order-2 order-lg-1 collapse" id="navbar-mobile">
...
</div>
<!-- /collapsible navbar content -->
<!-- Content that remains visible on mobile -->
<div class="nav justify-content-end order-1 order-lg-2">
...
</div>
<!-- /content that remains visible on mobile -->
</div>
</div>
<!-- /main navbar -->
<!-- Page content -->
<div class="page-content">
...
</div>
<!-- /page content -->
</body>
<!-- /document body -->
Bottom fixed navbar
Bottom fixed navbar markup is similar to static and top fixed, the only difference is it requires .fixed-bottom
class added to the <navbar>
container and proper body class to add bottom padding. Only available in layouts 3, 4, 5 and in static layouts of layouts 1 and 6.
<!-- Document body -->
<body class="navbar-bottom">
<!-- Page content -->
<div class="page-content">
...
</div>
<!-- /page content -->
<!-- Bottom navbar -->
<div class="navbar navbar-sm navbar-footer fixed-bottom border-top">
<div class="container-fluid">
<!-- Mobile togglers -->
<div class="d-flex d-lg-none me-2">
...
</div>
<!-- /mobile togglers -->
<!-- Navbar brand -->
<div class="navbar-brand flex-1 flex-lg-0">
...
</div>
<!-- /navbar brand -->
<!-- Left navigation (remains visible on mobile) -->
<ul class="nav">
...
</ul>
<!-- /left navigation (remains visible on mobile) -->
<!-- Collapsible navbar content -->
<div class="navbar-collapse justify-content-center flex-lg-1 order-2 order-lg-1 collapse" id="navbar-mobile">
...
</div>
<!-- /collapsible navbar content -->
<!-- Content that remains visible on mobile -->
<div class="nav justify-content-end order-1 order-lg-2">
...
</div>
<!-- /content that remains visible on mobile -->
</div>
</div>
<!-- /bottom navbar -->
</body>
<!-- /document body -->
Collapsed navbar
There is one additional option, when navbar doesn't have a logo and used as a toolbar. In this case the whole navbar becomes a link on mobiles and tables, all navbar content opens on click. Supports all options stated above:
<!-- Document body -->
<body>
<!-- Footer -->
<div class="navbar navbar-expand-lg navbar-static border-top">
<div class="container-fluid">
<div class="text-center d-lg-none w-100">
<button type="button" class="navbar-toggler dropdown-toggle" data-bs-toggle="collapse" data-bs-target="#navbar-second">
<i class="ph-list ms-2"></i>
Bottom navbar
</button>
</div>
<div class="navbar-collapse collapse" id="navbar-second">
...
</div>
</div>
</div>
<!-- /footer -->
</body>
<!-- /document body -->
Body classes
If you want to place navbar in non-static positions, you can 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 require custom classes added to the <body>
container to prevent overlap with other elements. The following table demonstrates the list of classes for <body>
container if navbar has non-static position.
Class | Description |
---|---|
.navbar-top |
This class adds top padding to the <body> container. Works only with default navbar height. If another height is specified, apply another class (see the line below). |
.navbar-bottom |
This class adds bottom padding to the <body> container. Works only with default navbar height. If another height is specified, apply another class (see the line below). |
.navbar-top-[size] |
Controls top spacing of <body> container, if navbar has optional height. Available sizes: small (*-sm ) and large (*-lg ). Default navbar requires .navbar-top class only. |
.navbar-bottom-[size] |
Controls bottom spacing of <body> container, if navbar has optional height. Available sizes: small (*-sm ) and large (*-lg ). Default navbar requires .navbar-bottom class only. |
.navbar-[size]-[size]-top |
Use these classes if the layout has multiple top navbars, where first [size] is the size of the first navbar, second [size] - height of the second navbar. In this particular use case, [size] can be: lg if large height, md is default height sm is small height.
|
.navbar-[size]-[size]-bottom |
Use these classes if the layout has multiple bottom navbars, where first [size] is the size of the first navbar, second [size] - height of the second navbar. In this particular use case, [size] can be: lg if large height, md is default height sm is small height.
|