bulma/docs/documentation/components/nav.html

186 lines
5.4 KiB
HTML
Raw Permalink Normal View History

---
layout: documentation
doc-tab: components
doc-subtab: nav
---
2018-03-26 13:46:39 +00:00
{% include subnav/subnav-components.html %}
<section class="section">
<div class="container">
2017-07-01 19:50:05 +00:00
2017-11-06 13:44:58 +00:00
<div class="message is-danger">
<div class="message-body">
<p>This component has been <strong>deprecated</strong>.</p>
2017-07-02 23:17:42 +00:00
</div>
2017-11-06 13:44:58 +00:00
</div>
2017-07-01 19:50:05 +00:00
2017-11-06 13:44:58 +00:00
<div class="message is-info">
<div class="message-body">
<p>While both <code>.nav</code> and <code>.navbar</code> currently co-exist to ensure backwards compatibility, the <code>.nav</code> will probably be deleted in an upcoming update, so you should start using <a href="{{ site.url }}/documentation/components/navbar/">the new navbar</a> instead.</p>
2017-07-02 23:17:42 +00:00
</div>
2017-11-06 13:44:58 +00:00
</div>
2017-07-01 19:50:05 +00:00
<h1 class="title">Nav</h1>
<h2 class="subtitle">
A responsive horizontal <strong>nav bar</strong> that can contain links, tabs, buttons, icons, and a logo
</h2>
<hr>
<div class="content">
<p>
The <code>nav</code> container can have <strong>3 parts</strong>:
</p>
<ul>
<li><code>nav-left</code></li>
<li><code>nav-center</code></li>
<li><code>nav-right</code></li>
</ul>
2016-12-23 13:20:13 +00:00
<p>
Each nav item needs to be wrapped in a <code>nav-item</code> element.
</p>
<p>
For responsiveness, <strong>2 additional</strong> classes are available:
</p>
<ul>
<li><code>nav-toggle</code> for the hamburger menu on mobile</li>
<li><code>nav-menu</code> for menu that is collapsable on mobile (you can combine it with <code>nav-right</code>)</li>
<li>toggle <code>is-active</code> on <code>nav-toggle</code> and <code>nav-menu</code> when <code>nav-toggle</code> was clicked</li>
</ul>
</div>
2016-12-23 13:20:13 +00:00
{% capture nav_example %}
<nav class="nav">
<div class="nav-left">
2018-04-08 11:31:05 +00:00
<a class="nav-item">
<img src="{{ site.url }}/images/bulma-logo.png" alt="Bulma logo">
</a>
</div>
<div class="nav-center">
2016-12-23 13:20:13 +00:00
<a class="nav-item">
<span class="icon">
2018-04-08 11:31:05 +00:00
<i class="fab fa-github"></i>
</span>
</a>
2016-12-23 13:20:13 +00:00
<a class="nav-item">
<span class="icon">
2018-04-08 11:31:05 +00:00
<i class="fab fa-twitter"></i>
</span>
</a>
</div>
2016-12-23 13:20:13 +00:00
<!-- This "nav-toggle" hamburger menu is only visible on mobile -->
<!-- You need JavaScript to toggle the "is-active" class on "nav-menu" -->
<span class="nav-toggle">
<span></span>
<span></span>
<span></span>
</span>
2016-12-23 13:20:13 +00:00
<!-- This "nav-menu" is hidden on mobile -->
<!-- Add the modifier "is-active" to display it on mobile -->
<div class="nav-right nav-menu">
2016-12-23 13:20:13 +00:00
<a class="nav-item">
Home
</a>
2016-12-23 13:20:13 +00:00
<a class="nav-item">
Documentation
</a>
2016-12-23 13:20:13 +00:00
<a class="nav-item">
Blog
</a>
2017-04-15 16:54:47 +00:00
<div class="nav-item">
<div class="field is-grouped">
<p class="control">
2018-04-08 11:31:05 +00:00
<a class="button" >
2017-04-15 16:54:47 +00:00
<span class="icon">
2018-04-08 11:31:05 +00:00
<i class="fab fa-twitter"></i>
2017-04-15 16:54:47 +00:00
</span>
<span>Tweet</span>
</a>
</p>
<p class="control">
<a class="button is-primary">
<span class="icon">
2018-04-08 11:31:05 +00:00
<i class="fas fa-download"></i>
2017-04-15 16:54:47 +00:00
</span>
<span>Download</span>
</a>
</p>
</div>
</div>
</div>
</nav>
2016-12-23 13:20:13 +00:00
{% endcapture %}
2017-08-14 11:44:24 +00:00
<div class="bd-example is-paddingless">
2016-12-23 13:20:13 +00:00
{{nav_example}}
</div>
{% highlight html %}
2016-12-23 13:20:13 +00:00
{{nav_example}}
{% endhighlight %}
<hr>
<h3 class="title">Modifiers</h3>
<div class="content">
<ul>
<li>the <code>nav</code> container can have a <strong>shadow</strong> by adding the <code>has-shadow</code> modifier</li>
<li>the <code>nav-item</code> can become <strong>active</strong> by adding the <code>is-active</code> modifier</li>
<li>the <code>nav-item</code> can become a <strong>tab</strong> by adding the <code>is-tab</code> modifier</li>
</ul>
2016-12-23 13:43:18 +00:00
<p>
To optimise the space on desktop, but also allow the mobile view to be usable, you can <strong>duplicate</strong> nav items in both <code>nav-left</code> and <code>nav-right</code>, and show/hide them with <a href="{{site.url}}/documentation/modifiers/responsive-helpers/">responsive helpers</a>.
</p>
</div>
</div>
2016-12-23 13:43:18 +00:00
{% capture nav_tabs_example %}
<nav class="nav has-shadow">
<div class="container">
<div class="nav-left">
2016-12-23 13:43:18 +00:00
<a class="nav-item">
2018-04-08 11:31:05 +00:00
<img src="{{ site.url }}/images/bulma-logo.png" alt="Bulma logo">
2016-12-23 13:43:18 +00:00
</a>
2018-04-08 11:31:05 +00:00
<a class="nav-item is-tab is-hidden-mobile is-active">Home</a>
2016-12-23 13:43:18 +00:00
<a class="nav-item is-tab is-hidden-mobile">Features</a>
<a class="nav-item is-tab is-hidden-mobile">Pricing</a>
<a class="nav-item is-tab is-hidden-mobile">About</a>
</div>
<span class="nav-toggle">
<span></span>
<span></span>
<span></span>
</span>
<div class="nav-right nav-menu">
2018-04-08 11:31:05 +00:00
<a class="nav-item is-tab is-hidden-tablet is-active">Home</a>
2016-12-23 13:43:18 +00:00
<a class="nav-item is-tab is-hidden-tablet">Features</a>
<a class="nav-item is-tab is-hidden-tablet">Pricing</a>
<a class="nav-item is-tab is-hidden-tablet">About</a>
<a class="nav-item is-tab">
<figure class="image is-16x16" style="margin-right: 8px;">
2018-04-08 11:31:05 +00:00
<img src="{{site.url}}/images/jgthms.png">
2016-12-23 13:43:18 +00:00
</figure>
Profile
</a>
<a class="nav-item is-tab">Log out</a>
</div>
</div>
</nav>
2016-12-23 13:43:18 +00:00
{% endcapture %}
2017-08-14 11:44:24 +00:00
<div class="bd-example is-paddingless">
2016-12-23 13:43:18 +00:00
{{nav_tabs_example}}
</div>
{% highlight html %}
2016-12-23 13:43:18 +00:00
{{nav_tabs_example}}
{% endhighlight %}
</section>