The navbar brand is always visible: on both touch devices < 1008px
and desktop >= 1008px
. As a result, it is recommended to only use a few navbar items to avoid overflowing horizontally on small devices.
<navclass="navbar"><divclass="navbar-brand"><aclass="navbar-item"href="https://versions.bulma.io/0.5.0"><imgsrc="https://versions.bulma.io/0.5.0/images/bulma-logo.png"alt="Bulma v0.5.0: a modern CSS framework based on Flexbox"width="112"height="28"></a><divclass="navbar-burger"><span></span><span></span><span></span></div></div></nav>
On desktop >= 1008px
, the navbar brand will only take up the space it needs.
Navbar burger
The navbar-burger is a hamburger menu that only appears on mobile. It has to appear as the last child of navbar-brand.
You can add the modifier class is-active to turn it into a cross.
Navbar menu
The navbar-menu is the counterpart of the navbar brand. As such, it must appear as a direct child of navbar, as a sibling of navbar-brand.
<navclass="navbar"><divclass="navbar-brand"><!-- navbar items, nav burger ... --></div><divclass="navbar-menu"><!-- navbar start, navbar end --></div></nav>
The navbar-menu is hidden on touch devices< 1008px
. You need to add the modifier class is-active to display it.
<divclass="navbar-menu"><!-- hidden on mobile --></div><divclass="navbar-menu is-active"><!-- shown on mobile --></div>
On desktop >= 1008px
, the navbar-menu will fill up the space available in the navbar, leaving the navbar brand just the space it needs. It needs, however, two elements as direct children:
navbar-start
navbar-end
Javascript toggle
The Bulma package does not come with any JavaScript.
Here is however an implementation example, which toggles the class is-active on both the navbar-burger and the targeted navbar-menu.
document.addEventListener('DOMContentLoaded',function(){// Get all "navbar-burger" elementsvar$navbarBurgers=Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'),0);// Check if there are any nav burgersif($navbarBurgers.length>0){// Add a click event on each of them$navbarBurgers.forEach(function($el){$el.addEventListener('click',()=>{// Get the target from the "data-target" attributevartarget=$el.dataset.target;var$target=document.getElementById(target);// Toggle the class on both the "navbar-burger" and the "navbar-menu"$el.classList.toggle('is-active');$target.classList.toggle('is-active');});});}});
Navbar start and navbar end
The navbar-start and navbar-end are the two direct and only children of the navbar-menu.
On desktop >= 1008px
:
navbar-start will appear on the left
navbar-end will appear on the right
Each of them can contain any number of navbar-item.
It can either be an anchor tag <a> or a <div>, as a direct child of either:
navbar
navbar-brand
navbar-start
navbar-end
navbar-dropdown
Transparent navbar
To seamlessly integrate the navbar in any visual context, you can add the is-transparent modifier on the navbar component. This will remove any hover or active background from the navbar items.
<navclass="navbar is-transparent"><divclass="navbar-brand"><aclass="navbar-item"href="https://versions.bulma.io/0.5.0"><imgsrc="https://versions.bulma.io/0.5.0/images/bulma-logo.png"alt="Bulma v0.5.0: a modern CSS framework based on Flexbox"width="112"height="28"></a><aclass="navbar-item is-hidden-desktop"href="https://github.com/jgthms/bulma"target="_blank"><spanclass="icon"style="color: #333;"><iclass="fa fa-github"></i></span></a><aclass="navbar-item is-hidden-desktop"href="https://twitter.com/jgthms"target="_blank"><spanclass="icon"style="color: #55acee;"><iclass="fa fa-twitter"></i></span></a><divclass="navbar-burger burger"data-target="navMenuTransparentExample"><span></span><span></span><span></span></div></div><divid="navMenuTransparentExample"class="navbar-menu"><divclass="navbar-start"><aclass="navbar-item "href="https://versions.bulma.io/0.5.0/">
Home
</a><divclass="navbar-item has-dropdown is-hoverable"><aclass="navbar-link is-active"href="/versions/0.5.0/documentation/overview/start/">
Docs
</a><divclass="navbar-dropdown is-boxed"><aclass="navbar-item "href="/versions/0.5.0/documentation/overview/start/">
Overview
</a><aclass="navbar-item "href="https://versions.bulma.io/0.5.0/documentation/modifiers/syntax/">
Modifiers
</a><aclass="navbar-item "href="https://versions.bulma.io/0.5.0/documentation/grid/columns/">
Grid
</a><aclass="navbar-item "href="https://versions.bulma.io/0.5.0/documentation/form/general/">
Form
</a><aclass="navbar-item "href="https://versions.bulma.io/0.5.0/documentation/elements/box/">
Elements
</a><aclass="navbar-item is-active"href="https://versions.bulma.io/0.5.0/documentation/components/breadcrumb/">
Components
</a><aclass="navbar-item "href="https://versions.bulma.io/0.5.0/documentation/layout/container/">
Layout
</a><hrclass="navbar-divider"><divclass="navbar-item"><div><pclass="is-size-6-desktop"><strongclass="has-text-info">0.5.0</strong></p><small><aclass="view-all-versions"href="/versions">View all versions</a></small></div></div></div></div><divclass="navbar-item has-dropdown is-hoverable"><aclass="navbar-link "href="https://versions.bulma.io/0.5.0/blog/">
Blog
</a><divid="blogDropdown"class="navbar-dropdown is-boxed"data-style="width: 18rem;"><aclass="navbar-item"href="/2017/07/24/access-previous-bulma-versions/"><divclass="navbar-content"><p><smallclass="has-text-info">24 Jul 2017</small></p><p>Access previous Bulma versions</p></div></a><aclass="navbar-item"href="/2017/03/10/new-field-element/"><divclass="navbar-content"><p><smallclass="has-text-info">10 Mar 2017</small></p><p>New field element (for better controls)</p></div></a><aclass="navbar-item"href="/2016/04/11/metro-ui-css-grid-with-bulma-tiles/"><divclass="navbar-content"><p><smallclass="has-text-info">11 Apr 2016</small></p><p>Metro UI CSS grid with Bulma tiles</p></div></a><aclass="navbar-item"href="https://versions.bulma.io/0.5.0/blog/">
More posts
</a><hrclass="navbar-divider"><divclass="navbar-item"><divclass="navbar-content"><divclass="level is-mobile"><divclass="level-left"><divclass="level-item"><strong>Stay up to date!</strong></div></div><divclass="level-right"><divclass="level-item"><aclass="button is-rss is-small"href="https://versions.bulma.io/0.5.0/atom.xml"><spanclass="icon is-small"><iclass="fa fa-rss"></i></span><span>Subscribe</span></a></div></div></div></div></div></div></div><divclass="navbar-item has-dropdown is-hoverable"><divclass="navbar-link">
More
</div><divid="moreDropdown"class="navbar-dropdown is-boxed"><aclass="navbar-item "href="https://versions.bulma.io/0.5.0/extensions/"><divclass="level is-mobile"><divclass="level-left"><divclass="level-item"><p><strong>Extensions</strong><br><small>Side projects to enhance Bulma</small></p></div></div><divclass="level-right"><divclass="level-item"><spanclass="icon has-text-info"><iclass="fa fa-plug"></i></span></div></div></div></a></div></div></div><divclass="navbar-end"><aclass="navbar-item"href="https://github.com/jgthms/bulma"target="_blank">
Github
</a><aclass="navbar-item"href="https://twitter.com/jgthms"target="_blank">
Twitter
</a><divclass="navbar-item"><divclass="field is-grouped"><pclass="control"><aid="twitter"class="button"data-social-network="Twitter"data-social-action="tweet"data-social-target="https://versions.bulma.io/0.5.0"target="_blank"href="https://twitter.com/intent/tweet?text=Bulma v0.5.0: a modern CSS framework based on Flexbox&url=https://versions.bulma.io/0.5.0&via=jgthms"><spanclass="icon"><iclass="fa fa-twitter"></i></span><span>Tweet</span></a></p><pclass="control"><aclass="button is-primary"href="https://github.com/jgthms/bulma/archive/0.5.0.zip"><spanclass="icon"><iclass="fa fa-download"></i></span><span>Download</span></a></p></div></div></div></div></nav>
Dropdown menu
To create a dropdown menu, you will need 4 elements:
navbar-item with the has-dropdown modifier
navbar-link which contains the dropdown arrow
navbar-dropdown which can contain instances of navbar-item and navbar-divider
<navclass="navbar"><divclass="navbar-item has-dropdown"><aclass="navbar-link">
Docs
</a><divclass="navbar-dropdown"><aclass="navbar-item">
Overview
</a><aclass="navbar-item">
Elements
</a><aclass="navbar-item">
Components
</a><hrclass="navbar-divider"><divclass="navbar-item">
Version 0.5.0
</div></div></div></nav>
Show/hide the dropdown with either CSS or JavaScript
The navbar-dropdown is visible on touch devices < 1008px
but hidden on desktop >= 1008px
. How the dropdown is displayed on desktop depends on the parent's class.
The navbar-item with the has-dropdown modifier, has 2 additional modifiers
is-hoverable: the dropdown will show up when hovering the parent navbar-item
is-active: the dropdown will show up all the time
While the CSS :hover implementation works perfectly, the is-active class is available for users who want to control the display of the dropdown with JavaScript.
<navclass="navbar"><divclass="navbar-item has-dropdown is-hoverable"><aclass="navbar-link">
Docs
</a><divclass="navbar-dropdown"><aclass="navbar-item">
Overview
</a><aclass="navbar-item">
Elements
</a><aclass="navbar-item">
Components
</a><hrclass="navbar-divider"><divclass="navbar-item">
Version 0.5.0
</div></div></div></nav>
<navclass="navbar"><divclass="navbar-item has-dropdown is-active"><aclass="navbar-link">
Docs
</a><divclass="navbar-dropdown"><aclass="navbar-item">
Overview
</a><aclass="navbar-item">
Elements
</a><aclass="navbar-item">
Components
</a><hrclass="navbar-divider"><divclass="navbar-item">
Version 0.5.0
</div></div></div></nav>
Styles for the dropdown menu
By default, the navbar-dropdown has:
a grey border-top
a border-radius at both bottom corners
Documentation
Everything you need to create a website with Bulma
<navclass="navbar"><aclass="navbar-item"><imgsrc="https://versions.bulma.io/0.5.0/images/bulma-logo.png"alt="Bulma v0.5.0: a modern CSS framework based on Flexbox"width="112"height="28"></a><divclass="navbar-item has-dropdown is-active"><aclass="navbar-link">
Docs
</a><divclass="navbar-dropdown"><aclass="navbar-item">
Overview
</a><aclass="navbar-item">
Elements
</a><aclass="navbar-item">
Components
</a><hrclass="navbar-divider"><divclass="navbar-item">
Version 0.5.0
</div></div></div></nav><sectionclass="hero is-primary"><divclass="hero-body"><pclass="title">
Documentation
</p><pclass="subtitle">
Everything you need to <strong>create a website</strong> with Bulma
</p></div></section>
When having a transparent navbar, it is preferable to use the boxed version of the dropdown, by using the is-boxed modifier.
the grey border is removed
a slight inner shadow is added
all corners are rounded
the hover/active state is animated
Documentation
Everything you need to create a website with Bulma
<navclass="navbar is-transparent"><aclass="navbar-item"><imgsrc="https://versions.bulma.io/0.5.0/images/bulma-logo.png"alt="Bulma v0.5.0: a modern CSS framework based on Flexbox"width="112"height="28"></a><divclass="navbar-item has-dropdown is-active"><aclass="navbar-link">
Docs
</a><divclass="navbar-dropdown is-boxed"><aclass="navbar-item">
Overview
</a><aclass="navbar-item">
Elements
</a><aclass="navbar-item">
Components
</a><hrclass="navbar-divider"><divclass="navbar-item">
Version 0.5.0
</div></div></div></nav><sectionclass="hero"><divclass="hero-body"><pclass="title">
Documentation
</p><pclass="subtitle">
Everything you need to <strong>create a website</strong> with Bulma
</p></div></section>
Active dropdown navbar item
Documentation
Everything you need to create a website with Bulma
<navclass="navbar"><aclass="navbar-item"><imgsrc="https://versions.bulma.io/0.5.0/images/bulma-logo.png"alt="Bulma v0.5.0: a modern CSS framework based on Flexbox"width="112"height="28"></a><divclass="navbar-item has-dropdown is-active"><aclass="navbar-link">
Docs
</a><divclass="navbar-dropdown"><aclass="navbar-item">
Overview
</a><aclass="navbar-item is-active">
Elements
</a><aclass="navbar-item">
Components
</a><hrclass="navbar-divider"><divclass="navbar-item">
Version 0.5.0
</div></div></div></nav><sectionclass="hero is-primary"><divclass="hero-body"><pclass="title">
Documentation
</p><pclass="subtitle">
Everything you need to <strong>create a website</strong> with Bulma
</p></div></section>
Dropdown divider
You can add a navbar-divider to display a horizontal rule in a navbar-dropdown.