Navbar

A lightweight header for your build with endless combinations to use in conjunction with the meshNav.

Usage

A navbar is a container to wrap branding, a menu and fields into one. The mesh navbar is a simple and lightweight design. We recommend using it to hold the mesh nav.
For more information regarding dropdowns & expanding head over to the the nav page.
Check out the examples below.

Notation:

  • The navbar is prefixed with the navbar class, its recommended you use the nav HTML semantic element like so, <nav class="navbar">.
  • The navbar usually consists of 2 or 3 child elements, depending on what you require; all of which are entirely optional, see below:
    1) Branding - Branding for your web build, which has no prefixed class, as you can achive it easily with our flex utility classes, see examples for more details.
    2) Nav - The mesh nav (<div class="nav-menu">), full docs can be found out the nav page.
    3) Input - A form element (usually a search bar like above), full docs can be found out the form page.
  • To add an active link, append one of the li's within the nav-menu with the active class.
  • The navbar background colour defaults to light grey, along with the text color to whatever default you have specified. To change them please refer to the Colors page

Position

Aligning content within the navbar is done so with our navbar-left, navbar-right, navbar-center classes.
These classes take advantage of the flex nature of the container, positioning nav items using the order property.

Right aligned links

The nav menu will naturally sit on the right hand side of the navbar providing its last in the DOM, if its not, add the navbar-right class to the menu.

<nav class="navbar">
    <div class="nav-menu navbar-right">
        <ul>
            <li class="nav-item"><a href="#">Item</a></li>
            <li class="nav-item"><a href="#">Item</a></li>
            <li class="nav-item"><a href="#">Item</a></li>
        </ul>
    </div>
    <a class="navbar-brand" href="#!">Logo</a>
    <div class="nav-btn">
        <img class="nav-icon" src="https://raw.githubusercontent.com/ainsleyclark/mesh/master/res/nav-menu.svg?sanitize=true">
    </div>
</nav>Copy iconSuccess icon

Left aligned links

Simply add the navbar-left property to the nav-menu. This will ensure links are preserved on the right at desktop only.
Note: If you prefer the nav menu (hamburger) to sit on the left at smaller viewports, re-arrange the nav-btn to sit as the first child of the navbar, see below:

<nav class="navbar">
    <div class="nav-btn">
        <img class="nav-icon" src="https://raw.githubusercontent.com/ainsleyclark/mesh/master/res/nav-menu.svg?sanitize=true">
    </div>
    <a class="navbar-brand" href="#!">Logo</a>
    <div class="nav-menu navbar-left">
        <ul>
            <li class="nav-item">
                <a href="#">Item</a>
            </li>
            <li class="nav-item">
                <a href="#">Item</a>
            </li>
            <li class="nav-item">
                <a href="#">Item</a>
            </li>
        </ul>
    </div>
</nav>Copy iconSuccess icon

Centering brand

Add the navbar-center property to any child element within the navbar which will absolutley position the item and center it horizontally.

<nav class="navbar my-3">
    <a class="navbar-brand" href="#!">Logo</a>
    <div class="nav-btn">
        <img class="nav-icon" src="https://raw.githubusercontent.com/ainsleyclark/mesh/master/res/nav-menu.svg?sanitize=true">
    </div>
    <div class="nav-menu navbar-left">
        <ul>
            <li class="nav-item">
                <a href="#">Item</a>
            </li>
            <li class="nav-item">
                <a href="#">Item</a>
            </li>
            <li class="nav-item">
                <a href="#">Item</a>
            </li>
        </ul>
    </div>
</nav>Copy iconSuccess icon

Fixed

It is positioned relative by default, to change this, simply add our fixed utility class p-fixed and pin-t, pin-l, full-width classes to pin the navbar to the top of the window.
For more information on the position property, head over to Free Code Camp.

<nav class="navbar p-fixed pin-l pin-t full-width">
    <a class="navbar-brand" href="#!">Logo</a>
    <div class="nav-btn">
        <img class="nav-icon" src="https://raw.githubusercontent.com/ainsleyclark/mesh/master/res/nav-menu.svg?sanitize=true">
    </div>
    <div class="nav-menu navbar-left">
        <ul>
            <li class="nav-item">
                <a href="#">Item</a>
            </li>
            <li class="nav-item">
                <a href="#">Item</a>
            </li>
            <li class="nav-item">
                <a href="#">Item</a>
            </li>
        </ul>
    </div>
</nav>Copy iconSuccess icon

Button

Using buttons within your navbar is as easy as inserting the predefined mesh button classes within the container. See the button page for more details.

<nav class="navbar">
    <a class="navbar-brand" href="#!">Logo</a>;
    <div class="nav-btn">
        <img class="nav-icon" src="https://raw.githubusercontent.com/ainsleyclark/mesh/master/res/nav-menu.svg?sanitize=true">
    </div>
    <div class="nav-menu">
        <ul>
            <li class="nav-item">
                <button class="btn btn-primary btn-small">Button</button>
            </li>
            <li class="nav-item">
                <button class="btn btn-primary">Button</button>
            </li>
            <li class="nav-item">
                <button class="btn btn-primary btn-large">Button</button>
            </li>
        </ul>
    </div>
</nav>Copy iconSuccess icon

Icon

Adding icons just a case of adding the <i> element inside the nav-item, see below:

<nav class="navbar my-3">
    <a class="navbar-brand" href="#!">Logo</a>
    <div class="nav-btn">
        <img class="nav-icon" src="https://raw.githubusercontent.com/ainsleyclark/mesh/master/res/nav-menu.svg?sanitize=true">
    </div>
    <div class="nav-menu">
        <ul>
            <li class="nav-item mx-1">
                <i class="fas fa-search"></i>
            </li>
            <li class="nav-item mx-1">
                <i class="fas fa-map-marker"></i>
            </li>
            <li class="nav-item mx-1">
                <i class="fas fa-heart"></i>
            </li>
            <li class="nav-item mx-1">
                <i class="fas fa-ellipsis-v"></i>
            </li>
        </ul>
    </div>
</nav>Copy iconSuccess icon

Tabs

To add materialistic tabs to the navbar, append the navbar container with the tabs component.
Then apply the navbar-tabs to the navbar element.
This will 0 out padding on the navbar and apply slight padding to the nav-menu and nav-brand elements.
Note: Be sure to add the navbar-dark and tabs-dark if you have a dark background selected like below.

<nav class="navbar navbar-tabs navbar-dark bg-secondary">
    <a class="navbar-brand" href="#!">Logo</a>
    <div class="nav-btn">
        <img class="nav-icon" src="https://raw.githubusercontent.com/ainsleyclark/mesh/master/res/nav-menu.svg?sanitize=true">
    </div>
    <div class="nav-menu">
        <ul>
            <li class="nav-item">
                <a class="active" href="#">Item</a>
            </li>
            <li class="nav-item">
                <a href="#">Item</a>
            </li>
            <li class="nav-item">
                <a href="#">Item</a>
            </li>
        </ul>
    </div>
    <div class="tabs tabs-animate tabs-dark">
        <input type="radio" class="tabs-toggle" name="tabs-animate" id="tab-animate-1" checked="checked">
        <label class="tabs-label" for="tab-animate-1">First Tab</label>
        <div class="tabs-panel">
            <h3>First Tab Content</h3>
            <p>+1 gluten-free fingerstache banh mi normcore...</p>
        </div>
        <input type="radio" class="tabs-toggle" name="tabs-animate" id="tab-animate-2">
        <label class="tabs-label" for="tab-animate-2">Second Tab</label>
        <div class="tabs-panel">
            <h3>Second Tab Content</h3>
            <p>Glossier brooklyn church-key, fingerstache...</p>
        </div>
        <input type="radio" class="tabs-toggle" name="tabs-animate" id="tab-animate-3">
        <label class="tabs-label" for="tab-animate-3">Third Tab</label>
        <div class="tabs-panel">
            <h3>Third Tab Content</h3>
            <p>Vexillologist messenger bag master...</p>
        </div>
    </div>
</nav>Copy iconSuccess icon

Colors

<nav class="navbar navbar-dark bg-dark">
    <!-- navbar content -->
</nav>
<nav class="navbar navbar-dark bg-primary">
    <!-- navbar content -->
</nav>
<nav class="navbar navbar-dark bg-secondary">
    <!-- navbar content -->
</nav>
<nav class="navbar navbar-dark bg-info">
    <!-- navbar content -->
</nav>Copy iconSuccess icon

Variables

Change padding amounts & default background color the navbar with the scss variables below.

Variable Value Description
$navbar-mobile-padding: 1.2em;
Pixel/em/rem Mobile & tablet padding amount in pixels, em's or rem's.
$navbar-padding: 1.2em 1.5em;
Pixel/em/rem Padding amount for default navbar in pixels, em's or rem's.
$navbar-margin-bottom: 20px;
Pixel/em/rem Margin bottom amount in pixels, em's or rem's.
$navbar-background-color: #ebeaea;
Color The default background color of the card.