Sticky secondary navbar
Secondary top (bottom) navbar can be also sticked to top (bottom) - this means the navbar toggles betweenrelative
and fixed
, depending on the scroll position. It is positioned relative until a given offset position is met in the viewport - then it "sticks" in place (like position: fixed;
). For cross browser support of sticky element, Limitless template uses StickyKitextension. As an alternative, you can also add .sticky-top
class to the secondary navbar, which adds position: sticky;
, but it's still considered as an experimental feature in some browsers.
Navbar component
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 static
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.
Static navbars
By default, top and bottom navbars 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 <body>
and placed before.page-content
container, bottom static navbar is placed afterit.
Fixed navbars
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. Thanks to the power of SASS, padding classes are dynamically calculated based on brand and nav link heights. Table below lists all available body and navbar classes.
Navbar markup
Navbar markup consists of a set of containers with mandatory and optional classes: .navbar
is a wrapper, this class is required for all types of navbars; .navbar-[color]
- sets main background color and adjusts content color; .navbar-expand-[breakpoint]
- responsible for collapsing navbar content behind the button on small screens; .navbar-component
- displays navbar as a stand alone component with borders and rounded corners. See the table below for a full list of classes.
Static navbar markup:
<!-- Document body --><body> <!-- Main navbar --> <div class="navbar navbar-dark navbar-expand-md"> <!-- Brand and responsive toggler --> <div class="navbar-header">...</div> <div class="d-md-none">...</div> <!-- Brand and responsive toggler --> <!-- Navbar content --> <div class="collapse navbar-collapse" id="navbar-main"> ... </div> <!-- /navbar content --> </div> <!-- /main navbar --> <!-- Secondary navbar --> <div class="navbar navbar-dark navbar-expand-md"> ... <!-- Navbar content --> <div class="collapse navbar-collapse" id="navbar-secondary"> ... </div> <!-- /navbar content --> </div> <!-- /secondary navbar --></body><!-- /document body -->
Fixed navbar markup:
<!-- Document body --><body class="navbar-md-md-top"> <!-- Navbars wrapper --> <div class="fixed-top"> <!-- Main navbar --> <div class="navbar navbar-dark navbar-expand-md"> <!-- Navbar content --> <div class="collapse navbar-collapse" id="navbar-main"> ... </div> <!-- /navbar content --> </div> <!-- /main navbar --> <!-- Secondary navbar --> <div class="navbar navbar-dark navbar-expand-md"> <!-- Navbar content --> <div class="collapse navbar-collapse" id="navbar-secondary"> ... </div> <!-- /navbar content --> </div> <!-- /secondary navbar --> </div> <!-- /navbars wrapper --></body><!-- /document body -->
Navbar classes
Class | Type | Description |
---|---|---|
.navbar
|
Required | Default navbar class, must be used with any navbar type and color. Responsible for basic navbar and navbar components styling as a parent container. |
.navbar-light
|
Required |
This class is used for dark background colors - default dark color is set in $navbar-light-bg variable, feel free to adjust the color according to your needs.
|
.navbar-light.alpha-*
|
Optional |
Combination of these classes allows you to set custom lightcolor to the light navbar. Note - .navbar-light is required, it's responsible for correct content styling.
|
.navbar-dark
|
Required |
This class is used for dark background colors - default dark color is set in $navbar-dark-bg variable, feel free to adjust the color according to your needs.
|
.navbar-dark.bg-*
|
Optional |
Combination of these classes allows you to set custom darkcolor to the dark navbar. Note - .navbar-dark is required, it's responsible for correct content styling.
|
.navbar-expand-[breakpoint]
|
Optional |
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. Otherwise use this class to change when navbar content collapses behind a button.
|
.navbar-header
|
Optional |
Navbar brand wrapper. This class is responsible for navbar logo section with custom background color. Must contain children .navbar-brand container(s).
|
.navbar-brand
|
Required | Class for logo container. It can be applied to most elements, but an anchor works best as some elements might require utility classes or custom styles |
.navbar-brand-[md, xs]
|
Required |
These classes toggle logos - xs is hidden by default and is visible if main sidebar is collapsed, md is visible by default and is hidden when main sidebar is expanded
|
.navbar-toggler
|
Required | This class needs to be added to the navbar toggle button that toggles navbar content on small screens. Always used with visibility utility classes. |
.navbar-collapse
|
Required | Groups and hides navbar contents by a parent breakpoint. Requires an ID for targeting collapsible container when sidebar content is collapsed. |
.navbar-nav
|
Required | Responsive navigation container class that adds default styling for navbar navigation. |
.nav-item
|
Required | Wrapper class for immediate parents of all navigation links. Responsible for correct styling of nav items |
.navbar-nav-link
|
Required |
Custom class for links within .navbar-nav list, it sets proper styling for links in light and dark navbars.
|
.navbar-text
|
Required | This class adjusts vertical alignment and horizontal spacing for strings of text |
.navbar-component
|
Optional | Display navbar as a stand alone component, with border and rounded corners. |
.fixed-top
|
Optional |
Makes navbar sticked to the top of the page. Requires proper class for <body> container, see the table below.
|
.fixed-bottom
|
Optional |
Makes navbar sticked to the bottom of the page. Requires proper class for <body> container, see the table below.
|
.sticky-top
|
Optional |
Adds position: sticky; to the navbar - it's treated as relatively positioned until its containing block crosses a specified threshold, at which point it is treated as fixed. Support is limited.
|
Body classes
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-top-[size]-[size]
|
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-bottom-[size]-[size]
|
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.
|