group: components
---
-The navbar is a simple wrapper for positioning branding, navigation, and other elements. It's easily extensible and with the help of our collapse plugin it can easily integrate offscreen content.
+The navbar is a simple wrapper for positioning branding, navigation, and other elements. It's easily extensible and, with the help of our collapse plugin, it can easily integrate offscreen content.
## Contents
* Will be replaced with the ToC, excluding the "Contents" header
{:toc}
-### Basics
+## Basics
Here's what you need to know before getting started with the navbar:
-- Navbars require a wrapping `.navbar` and either a color scheme class or custom styles.
+- Navbars require a wrapping `.navbar` and a color scheme class (either `.navbar-default` or `.navbar-inverse`).
- When using multiple components in a navbar, some [alignment classes](#alignment) are required.
- Navbars and their contents are fluid by default. Use [optional containers](#containers) to limit their horizontal width.
+- Use `.pull-left` and `.pull-right` to quickly align sub-components.
- Ensure accessibility by using a `<nav>` element or, if using a more generic element such as a `<div>`, add a `role="navigation"` to every navbar to explicitly identify it as a landmark region for users of assistive technologies.
-### Branding
+## Supported content
-Name your company, product, or project with `.navbar-brand`.
+Navbars come with built-in support for a handful of sub-components. Mix and match from the following as you need:
-{% example html %}
-<nav class="navbar navbar-default">
- <h3 class="navbar-brand">
- <a href="#">Navbar</a>
- </h3>
-</nav>
-{% endexample %}
+- `.navbar-brand` for your company, product, or project name
+- `.navbar-nav` for a full-height and lightweight navigation (including support for dropdowns)
+- `.navbar-form` for vertically centering default-sized inputs and buttons.
-### Navigation
-
-Use `.nav-pills` within a navbar for basic navigation.
+Here's an example of all the sub-components included in a default, light navbar:
{% example html %}
<nav class="navbar navbar-default">
- <ul class="nav nav-pills">
+ <a class="navbar-brand" href="#">Navbar</a>
+ <ul class="nav navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<a class="nav-link" href="#">About</a>
</li>
</ul>
-</nav>
-{% endexample %}
-
-### Inline forms
-
-Add an `.inline-form` within the navbar with nearly any combination of form controls and buttons.
-
-{% example html %}
-<nav class="navbar navbar-default">
- <form class="form-inline">
+ <form class="form-inline navbar-form pull-right">
<input class="form-control" type="text" placeholder="Search">
- <button class="btn btn-primary" type="submit">Search</button>
+ <button class="btn btn-success-outline" type="submit">Search</button>
</form>
</nav>
{% endexample %}
-### Containers
-
-Although it's not required, you can wrap a navbar in a `.container` to center it on a page, or add one within to only center the contents of the navbar.
-
-{% example html %}
-<div class="container">
- <nav class="navbar navbar-default">
- <h3 class="navbar-brand">
- <a href="#">Navbar</a>
- </h3>
- </nav>
-</div>
-{% endexample %}
-
-{% example html %}
-<nav class="navbar navbar-default">
- <div class="container">
- <h3 class="navbar-brand">
- <a href="#">Navbar</a>
- </h3>
- </div>
-</nav>
-{% endexample %}
-
-### Alignment
-
-Use `.pull-left` or `.pull-right` to align multiple elements within the navbar.
-
-{% example html %}
-<nav class="navbar navbar-default">
- <h3 class="navbar-brand pull-left">
- <a href="#">Navbar</a>
- </h3>
- <ul class="nav nav-pills pull-left">
- <li class="nav-item active">
- <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
- </li>
- <li class="nav-item">
- <a class="nav-link" href="#">Features</a>
- </li>
- <li class="nav-item">
- <a class="nav-link" href="#">Pricing</a>
- </li>
- <li class="nav-item">
- <a class="nav-link" href="#">About</a>
- </li>
- </ul>
- <ul class="nav nav-pills pull-right">
- <li class="nav-item">
- <a class="nav-link" href="#">Help</a>
- </li>
- <li class="nav-item">
- <a class="nav-link" href="#">Sign out</a>
- </li>
- </ul>
-</nav>
-{% endexample %}
-
-### Inverse color scheme
+## Inverse theme
-Replace `.navbar-default` with `.navbar-inverse` for a darker background color and white text.
+When you want a darker navbar with light text colors, replace the `.navbar-default` with `.navbar-inverse`.
{% example html %}
<nav class="navbar navbar-inverse">
- <h3 class="navbar-brand pull-left">
- <a href="#">Navbar</a>
- </h3>
- <ul class="nav nav-pills pull-left">
+ <a class="navbar-brand" href="#">Navbar</a>
+ <ul class="nav navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<a class="nav-link" href="#">About</a>
</li>
</ul>
- <form class="form-inline pull-right">
+ <form class="form-inline navbar-form pull-right">
<input class="form-control" type="text" placeholder="Search">
- <button class="btn btn-primary" type="submit">Search</button>
+ <button class="btn btn-success-outline" type="submit">Search</button>
</form>
</nav>
{% endexample %}
-### Small navbar
+## Containers
-Small navbars provide a similar aesthetic to Bootstrap 3's navbar. It cuts the padding down, enables full-height navigation, and tweaks vertical alignment for search forms, buttons, and more. It's also available in both default and inverse schemes.
+Although it's not required, you can wrap a navbar in a `.container` to center it on a page or add one within to only center the contents of the navbar.
-When moving from a regular navbar to a small one, be sure to update your inputs and buttons to use their small variations as well.
-
-<div class="bd-example">
- <nav class="navbar navbar-default navbar-sm">
- <h3 class="navbar-brand pull-left">
- <a href="#">Navbar</a>
- </h3>
- <ul class="nav navbar-nav pull-left">
- <li class="nav-item active">
- <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
- </li>
- <li class="nav-item">
- <a class="nav-link" href="#">Features</a>
- </li>
- <li class="nav-item">
- <a class="nav-link" href="#">Pricing</a>
- </li>
- <li class="nav-item">
- <a class="nav-link" href="#">About</a>
- </li>
- </ul>
- <form class="form-inline pull-right">
- <input class="form-control form-control-sm" type="text" placeholder="Search">
- <button class="btn btn-sm btn-primary" type="submit">Search</button>
- </form>
- </nav>
-
- <nav class="navbar navbar-inverse navbar-sm">
- <h3 class="navbar-brand pull-left">
- <a href="#">Navbar</a>
- </h3>
- <ul class="nav navbar-nav pull-left">
- <li class="nav-item active">
- <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
- </li>
- <li class="nav-item">
- <a class="nav-link" href="#">Features</a>
- </li>
- <li class="nav-item">
- <a class="nav-link" href="#">Pricing</a>
- </li>
- <li class="nav-item">
- <a class="nav-link" href="#">About</a>
- </li>
- </ul>
- <form class="form-inline pull-right">
- <input class="form-control form-control-sm" type="text" placeholder="Search">
- <button class="btn btn-sm btn-primary" type="submit">Search</button>
- </form>
+{% example html %}
+<div class="container">
+ <nav class="navbar navbar-default">
+ <a class="navbar-brand" href="#">Navbar</a>
</nav>
</div>
+{% endexample %}
-{% highlight html %}
-<nav class="navbar navbar-default navbar-sm">
- <!-- Navbar contents -->
-</nav>
-
-<nav class="navbar navbar-inverse navbar-sm">
- <!-- Navbar contents -->
+{% example html %}
+<nav class="navbar navbar-default">
+ <div class="container">
+ <a class="navbar-brand" href="#">Navbar</a>
+ </div>
</nav>
-{% endhighlight %}
+{% endexample %}
-### Collapsible content
+## Collapsible content
Our collapse plugin allows you to use a `<button>` or `<a>` to toggle hidden content.
<div class="collapse" id="exCollapsingNavbar">
<div class="inverse p-a">
<h4>Collapsed content</h4>
- <p>Toggleable via the navbar brand.</p>
+ <span class="text-muted">Toggleable via the navbar brand.</span>
</div>
</div>
<nav class="navbar navbar-default">
☰
</button>
<div class="collapse navbar-toggleable-xs" id="exCollapsingNavbar2">
- <h4>Collapsed on xs devices</h4>
- <p>Toggleable via the navbar brand.</p>
+ <a class="navbar-brand" href="#">Responsive navbar</a>
+ <ul class="nav navbar-nav">
+ <li class="nav-item active">
+ <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
+ </li>
+ <li class="nav-item">
+ <a class="nav-link" href="#">Features</a>
+ </li>
+ <li class="nav-item">
+ <a class="nav-link" href="#">Pricing</a>
+ </li>
+ <li class="nav-item">
+ <a class="nav-link" href="#">About</a>
+ </li>
+ </ul>
</div>
</nav>
{% endexample %}
.navbar {
position: relative;
- padding: $spacer;
- margin-bottom: $navbar-margin-bottom;
@include clearfix;
@include media-breakpoint-up(sm) {
}
-//
// Navbar alignment options
//
// Display the navbar across the entirety of the page or fixed it to the top or
}
+//
// Brand/project name
+//
.navbar-brand {
float: left;
- padding: .625rem .75rem;
- margin-right: $spacer;
- margin-bottom: 0; // For headings
+ padding: .95rem 1rem;
font-size: $font-size-lg;
line-height: 1;
+ color: $navbar-default-brand-color;
- > a {
- @include hover-focus {
- text-decoration: none;
- }
+ @include hover-focus {
+ color: $navbar-default-brand-hover-color;
+ text-decoration: none;
}
> img {
// Bootstrap JavaScript plugin.
.navbar-toggler {
- padding: .55rem .75rem;
- margin-right: $spacer;
- margin-bottom: 0; // For headings
+ padding: .5rem .75rem;
+ margin-top: .375rem;
+ margin-bottom: .375rem;
font-size: $font-size-lg;
line-height: 1;
+ color: $navbar-default-link-color;
background: none;
- border: 0;
+ border: $border-width solid transparent;
+ @include border-radius($btn-border-radius);
@include hover-focus {
text-decoration: none;
}
-// Dropdown menus
-
-// Menu position and menu carets
-.navbar-nav > li > .dropdown-menu {
- margin-top: 0;
- @include border-top-radius(0);
-}
-// Menu position and menu caret support for dropups via extra dropup class
-.navbar-fixed-bottom .navbar-nav > li > .dropdown-menu {
- @include border-top-radius($navbar-border-radius);
- @include border-bottom-radius(0);
-}
-
-
-// Small navbar
+// Navigation
//
-// Condensed dimensions for an aesthetic closer to v3's navbar.
-
-.navbar-sm {
- padding-top: 0;
- padding-bottom: 0;
-
- .navbar-brand {
- padding-top: .95rem;
- padding-bottom: .95rem;
- }
-
- .form-inline {
- margin-top: .6rem;
- }
-}
+// Custom navbar navigation built on the base `.nav` styles.
.navbar-nav {
.nav-item {
.nav-link {
display: block;
- padding-top: .95rem;
- padding-bottom: .95rem;
+ padding: .95rem .75rem;
line-height: 1.25; // Match the `.navbar-brand`
+ color: $navbar-default-link-color;
+
+ @include hover-focus {
+ color: $navbar-default-link-hover-color;
+ background-color: $navbar-default-link-hover-bg;
+ }
}
.open > .nav-link,
}
+// Forms
+//
+// Additional modifier class to add to `.form-inline` to vertically center forms.
+
+.navbar-form {
+ margin-top: .375rem;
+ margin-bottom: .375rem;
+ margin-right: 1rem;
+}
+
+
+//
// Alternate navbars
-// --------------------------------------------------
+//
// todo: audit these styles
background-color: $navbar-inverse-bg;
border-color: $navbar-inverse-border;
- .navbar-toggler,
- .navbar-brand > a,
- .nav-pills > .nav-item > .nav-link {
- color: $navbar-inverse-link-color;
-
- @include hover-focus {
- color: $navbar-inverse-link-hover-color;
- }
- }
- .nav-pills > .nav-item > .nav-link {
- @include hover-focus {
- color: $navbar-inverse-link-active-color;
- background-color: $navbar-inverse-link-active-bg;
- }
- }
- .nav-pills > .active > .nav-link,
- .nav-pills > .nav-link.active {
- color: $navbar-inverse-link-active-color;
- background-color: $navbar-inverse-link-active-bg;
- }
-
.navbar-brand {
color: $navbar-inverse-brand-color;
+
@include hover-focus {
color: $navbar-inverse-brand-hover-color;
background-color: $navbar-inverse-brand-hover-bg;
}
.navbar-nav {
- .navbar-link {
+ .nav-link {
color: $navbar-inverse-link-color;
@include hover-focus {
color: $navbar-inverse-link-hover-color;
background-color: $navbar-inverse-link-hover-bg;
}
+ }
- &.active > a {
- @include plain-hover-focus {
- color: $navbar-inverse-link-active-color;
- background-color: $navbar-inverse-link-active-bg;
- }
- }
-
- &.disabled > a {
- @include plain-hover-focus {
- color: $navbar-inverse-link-disabled-color;
- background-color: $navbar-inverse-link-disabled-bg;
- }
+ .open > .nav-link,
+ .active > .nav-link,
+ .nav-link.open,
+ .nav-link.active {
+ @include plain-hover-focus {
+ color: $navbar-inverse-link-active-color;
+ background-color: $navbar-inverse-link-active-bg;
}
}
}
- // .navbar-collapse,
- // .navbar-form {
- // border-color: darken($navbar-inverse-bg, 7%);
- // }
- //
- // // Dropdowns
- // .navbar-nav {
- // > .open > a {
- // @include plain-hover-focus {
- // color: $navbar-inverse-link-active-color;
- // background-color: $navbar-inverse-link-active-bg;
- // }
- // }
- // }
-
- // .navbar-link {
- // color: $navbar-inverse-link-color;
- // @include hover {
- // color: $navbar-inverse-link-hover-color;
- // }
- // }
- //
- // .btn-link {
- // color: $navbar-inverse-link-color;
- //
- // @include hover-focus {
- // color: $navbar-inverse-link-hover-color;
- // }
- //
- // &:disabled,
- // fieldset[disabled] & {
- // @include hover-focus {
- // color: $navbar-inverse-link-disabled-color;
- // }
- // }
- // }
+ .navbar-toggler {
+ color: $navbar-inverse-link-color;
+ }
}