---
title: Top Bar
meta: Top-bar navigation
---
***
***
### Build With HTML Classes
The top bar is a pretty complex piece of magical UI goodness. We rely on many presentational classes to define its look and feel, and there's a lot happening in the JS. The top bar is hoverable by default, but you can change it use click events instead by adding `data-options="is_hover: false"` to the `` element. [See an example below](#clickable).
#### HTML
{{#markdown}}
```html
{{> examples_topbar_default}}
```
{{/markdown}}
***
### Positioning the Bar
The top bar is built with a single `nav` element with a class of `top-bar`. It will take on full-browser width by default. To make the top bar stay fixed as you scroll, wrap it in `div class="fixed"`. If you want your navigation to be set to your grid width, wrap it in `div class="contain-to-grid"`. You may use `fixed` and `contain-to-grid` together in the wrapping div (`div class="contain-to-grid fixed`).
Fixed Navigation
{{#markdown}}
```html
...
```
{{/markdown}}
Contain to Grid
{{#markdown}}
```html
...
```
{{/markdown}}
***
### Sticky Top Bar
You may also wrap your top bar in `div class="sticky"` and put it anywhere within your markup. When the navigation hits the top of the browser, it will act like the fixed top bar and stick to the top as users continue to scroll. **Note:** If you are using SCSS, you can control the default `sticky` class by adjusting the `$topbar-sticky-class` variable. **Make sure the JS variable for `sticky_class` matches whatever class you use in the variable.**
{{> examples_topbar_sticky}}
You can now also add `sticky_on` to your `data-options` attribute to allow your sticky bar to work on `small`, `medium`, or `large` when the page loads. It will be sticky on all screen sizes by default.
{{#markdown}}
```html
...
```
{{/markdown}}
***
### Clickable Top Bar
You can now make the top bar clickable by adding a data-attribute to the nav element. Here's an example:
{{> examples_topbar_clickable}}
{{#markdown}}
```html
```
{{/markdown}}
***
### Built-in Components
Several common elements have been supported by default, each one of these elements gets added to either the `ul.right` or `ul.left` unordered lists within your Top Bar navigation.
##### Search Bar
{{#markdown}}
```html
```
{{/markdown}}
##### Divider
{{#markdown}}
```html
```
{{/markdown}}
##### Button
{{#markdown}}
```html
Get Lucky
```
{{/markdown}}
***
### Remove the Title
If you want a bar that doesn't include a title, just take out the content within the list item, like so:
{{#markdown}}
```html
```
{{/markdown}}
***
### Available SCSS Variables
We do include SCSS variable to help you control some of the styles for the top bar. Overall the styles are written mobile first, so they are much easier to override than the previous iteration of the top bar.
{{> examples_topbar_variables}}
**Note:** `rem-calc();` is a function we wrote to convert `px` to `rem`. It is included in **_variables.scss**.
***
### Using the Javascript
Before you can use the top bar you'll want to verify that jQuery and `foundation.js` are available on your page. You can refer to the [Javascript documentation](../javascript.html) on setting that up.
Just add `foundation.topbar.js` AFTER the `foundation.js` file. Your markup should look something like this:
{{#markdown}}
```html
...
```
{{/markdown}}
Required Foundation Library: `foundation.topbar.js`
##### Optional Javascript Configuration
Top bar supports `data-options` configuration.
{{#markdown}}
```js
{
sticky_class : 'sticky',
custom_back_text: true, // Set this to false and it will pull the top level link name as the back text
back_text: 'Back', // Define what you want your custom back text to be if custom_back_text: true
is_hover: true,
mobile_show_parent_link: false, // will copy parent links into dropdowns for mobile navigation
scrolltop : true // jump to top when sticky nav menu toggle is clicked
}
```
{{/markdown}}
***
### Sass Errors?
If the default "foundation" import was commented out, then make sure you import this file:
SCSS
```scss
@import "foundation/components/top-bar";
```