navbar.html 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062
  1. ---
  2. title: Navbar
  3. layout: documentation
  4. doc-tab: components
  5. doc-subtab: navbar
  6. ---
  7. {% include subnav-components.html %}
  8. {% capture navbar_example %}
  9. {% include examples/navbar.html id="Default" %}
  10. {% endcapture %}
  11. {% capture navbar_brand_example %}
  12. <nav class="navbar" role="navigation" aria-label="main navigation">
  13. <div class="navbar-brand">
  14. <!-- navbar items, navbar burger... -->
  15. </div>
  16. </nav>
  17. {% endcapture %}
  18. {% capture navbar_burger_example %}
  19. <button class="button navbar-burger">
  20. <span></span>
  21. <span></span>
  22. <span></span>
  23. </button>
  24. {% endcapture %}
  25. {% capture navbar_brand_items_example %}
  26. <nav class="navbar" role="navigation" aria-label="main navigation">
  27. <div class="navbar-brand">
  28. <a class="navbar-item" href="{{ site.url }}">
  29. <img src="{{ site.url }}/images/bulma-logo.png" alt="{{ site.title }}" width="112" height="28">
  30. </a>
  31. <button class="button navbar-burger">
  32. <span></span>
  33. <span></span>
  34. <span></span>
  35. </button>
  36. </div>
  37. </nav>
  38. {% endcapture %}
  39. {% capture navbar_menu_example %}
  40. <nav class="navbar" role="navigation" aria-label="main navigation">
  41. <div class="navbar-brand">
  42. <!-- navbar items, navbar burger... -->
  43. </div>
  44. <div class="navbar-menu">
  45. <!-- navbar start, navbar end -->
  46. </div>
  47. </nav>
  48. {% endcapture %}
  49. {% capture navbar_menu_active_example %}
  50. <div class="navbar-menu">
  51. <!-- hidden on mobile -->
  52. </div>
  53. <div class="navbar-menu is-active">
  54. <!-- shown on mobile -->
  55. </div>
  56. {% endcapture %}
  57. {% capture navbar_start_end_example %}
  58. <div class="navbar-menu">
  59. <div class="navbar-start">
  60. <!-- navbar items -->
  61. </div>
  62. <div class="navbar-end">
  63. <!-- navbar items -->
  64. </div>
  65. </div>
  66. {% endcapture %}
  67. {% capture navbar_item_link_example %}
  68. <a class="navbar-item">
  69. Home
  70. </a>
  71. {% endcapture %}
  72. {% capture navbar_item_brand_example %}
  73. <a class="navbar-item">
  74. <img src="{{ site.url }}/images/bulma-logo.png" width="112" height="28" alt="Bulma">
  75. </a>
  76. {% endcapture %}
  77. {% capture navbar_item_dropdown_example %}
  78. <div class="navbar-item has-dropdown">
  79. <a class="navbar-link">
  80. Docs
  81. </a>
  82. <div class="navbar-dropdown">
  83. <!-- Other navbar items -->
  84. </div>
  85. </div>
  86. {% endcapture %}
  87. {% capture navbar_item_dropdown_bis_example %}
  88. <div class="navbar-dropdown">
  89. <a class="navbar-item">
  90. Overview
  91. </a>
  92. </div>
  93. {% endcapture %}
  94. {% capture navbar_item_other_example %}
  95. <div class="navbar-item">
  96. <div class="field is-grouped">
  97. <p class="control">
  98. <a class="button">
  99. <span class="icon">
  100. <i class="fa fa-twitter" aria-hidden="true"></i>
  101. </span>
  102. <span>Tweet</span>
  103. </a>
  104. </p>
  105. <p class="control">
  106. <a class="button is-primary">
  107. <span class="icon">
  108. <i class="fa fa-download" aria-hidden="true"></i>
  109. </span>
  110. <span>Download</span>
  111. </a>
  112. </p>
  113. </div>
  114. </div>
  115. {% endcapture %}
  116. {% capture navbar_transparent_example %}
  117. {% include examples/navbar.html transparent=true boxed=true id="TransparentExample" %}
  118. {% endcapture %}
  119. {% capture navbar_dropdown_example %}
  120. <nav class="navbar" role="navigation" aria-label="dropdown navigation">
  121. <div class="navbar-item has-dropdown">
  122. <a class="navbar-link">
  123. Docs
  124. </a>
  125. <div class="navbar-dropdown">
  126. <a class="navbar-item">
  127. Overview
  128. </a>
  129. <a class="navbar-item">
  130. Elements
  131. </a>
  132. <a class="navbar-item">
  133. Components
  134. </a>
  135. <hr class="navbar-divider">
  136. <div class="navbar-item">
  137. Version {{ site.version }}
  138. </div>
  139. </div>
  140. </div>
  141. </nav>
  142. {% endcapture %}
  143. {% capture navbar_dropdown_hover_snippet %}
  144. <div class="navbar-item has-dropdown is-hoverable">
  145. <!-- navbar-link, navbar-dropdown etc. -->
  146. </div>
  147. {% endcapture %}
  148. {% capture navbar_dropdown_hover_example %}
  149. <nav class="navbar" role="navigation" aria-label="dropdown navigation">
  150. <div class="navbar-item has-dropdown is-hoverable">
  151. <a class="navbar-link">
  152. Docs
  153. </a>
  154. <div class="navbar-dropdown">
  155. <a class="navbar-item">
  156. Overview
  157. </a>
  158. <a class="navbar-item">
  159. Elements
  160. </a>
  161. <a class="navbar-item">
  162. Components
  163. </a>
  164. <hr class="navbar-divider">
  165. <div class="navbar-item">
  166. Version {{ site.version }}
  167. </div>
  168. </div>
  169. </div>
  170. </nav>
  171. {% endcapture %}
  172. {% capture navbar_dropdown_active_snippet %}
  173. <div class="navbar-item has-dropdown is-active">
  174. <!-- navbar-link, navbar-dropdown etc. -->
  175. </div>
  176. {% endcapture %}
  177. {% capture navbar_dropdown_active_example %}
  178. <nav class="navbar" role="navigation" aria-label="dropdown navigation">
  179. <div class="navbar-item has-dropdown is-active">
  180. <a class="navbar-link">
  181. Docs
  182. </a>
  183. <div class="navbar-dropdown">
  184. <a class="navbar-item">
  185. Overview
  186. </a>
  187. <a class="navbar-item">
  188. Elements
  189. </a>
  190. <a class="navbar-item">
  191. Components
  192. </a>
  193. <hr class="navbar-divider">
  194. <div class="navbar-item">
  195. Version {{ site.version }}
  196. </div>
  197. </div>
  198. </div>
  199. </nav>
  200. {% endcapture %}
  201. {% capture navbar_dropdown_right_snippet %}
  202. <div class="navbar-dropdown is-right">
  203. <!-- navbar-item, navbar-divider etc. -->
  204. </div>
  205. {% endcapture %}
  206. {% capture navbar_dropdown_right_example %}
  207. <nav class="navbar" role="navigation" aria-label="dropdown navigation">
  208. <div class="navbar-menu">
  209. <div class="navbar-start">
  210. <div class="navbar-item has-dropdown is-active">
  211. <a class="navbar-link">
  212. Left
  213. </a>
  214. <div class="navbar-dropdown">
  215. <a class="navbar-item">
  216. Overview
  217. </a>
  218. <a class="navbar-item">
  219. Elements
  220. </a>
  221. <a class="navbar-item">
  222. Components
  223. </a>
  224. <hr class="navbar-divider">
  225. <div class="navbar-item">
  226. Version {{ site.version }}
  227. </div>
  228. </div>
  229. </div>
  230. </div>
  231. <div class="navbar-end">
  232. <div class="navbar-item has-dropdown is-active">
  233. <a class="navbar-link">
  234. Right
  235. </a>
  236. <div class="navbar-dropdown is-right">
  237. <a class="navbar-item">
  238. Overview
  239. </a>
  240. <a class="navbar-item">
  241. Elements
  242. </a>
  243. <a class="navbar-item">
  244. Components
  245. </a>
  246. <hr class="navbar-divider">
  247. <div class="navbar-item">
  248. Version {{ site.version }}
  249. </div>
  250. </div>
  251. </div>
  252. </div>
  253. </div>
  254. </nav>
  255. <section class="hero is-primary">
  256. <div class="hero-body">
  257. <p class="title">
  258. Documentation
  259. </p>
  260. <p class="subtitle">
  261. Everything you need to <strong>create a website</strong> with Bulma
  262. </p>
  263. </div>
  264. </section>
  265. {% endcapture %}
  266. {% capture navbar_dropdown_default_example %}
  267. <nav class="navbar" role="navigation" aria-label="dropdown navigation">
  268. <a class="navbar-item">
  269. <img src="{{ site.url }}/images/bulma-logo.png" alt="{{ site.title }}" width="112" height="28">
  270. </a>
  271. <div class="navbar-item has-dropdown is-active">
  272. <a class="navbar-link">
  273. Docs
  274. </a>
  275. <div class="navbar-dropdown">
  276. <a class="navbar-item">
  277. Overview
  278. </a>
  279. <a class="navbar-item">
  280. Elements
  281. </a>
  282. <a class="navbar-item">
  283. Components
  284. </a>
  285. <hr class="navbar-divider">
  286. <div class="navbar-item">
  287. Version {{ site.version }}
  288. </div>
  289. </div>
  290. </div>
  291. </nav>
  292. <section class="hero is-primary">
  293. <div class="hero-body">
  294. <p class="title">
  295. Documentation
  296. </p>
  297. <p class="subtitle">
  298. Everything you need to <strong>create a website</strong> with Bulma
  299. </p>
  300. </div>
  301. </section>
  302. {% endcapture %}
  303. {% capture navbar_dropdown_boxed_example %}
  304. <nav class="navbar is-transparent" role="navigation" aria-label="dropdown navigation">
  305. <a class="navbar-item">
  306. <img src="{{ site.url }}/images/bulma-logo.png" alt="{{ site.title }}" width="112" height="28">
  307. </a>
  308. <div class="navbar-item has-dropdown is-active">
  309. <a class="navbar-link">
  310. Docs
  311. </a>
  312. <div class="navbar-dropdown is-boxed">
  313. <a class="navbar-item">
  314. Overview
  315. </a>
  316. <a class="navbar-item">
  317. Elements
  318. </a>
  319. <a class="navbar-item">
  320. Components
  321. </a>
  322. <hr class="navbar-divider">
  323. <div class="navbar-item">
  324. Version {{ site.version }}
  325. </div>
  326. </div>
  327. </div>
  328. </nav>
  329. <section class="hero">
  330. <div class="hero-body">
  331. <p class="title">
  332. Documentation
  333. </p>
  334. <p class="subtitle">
  335. Everything you need to <strong>create a website</strong> with Bulma
  336. </p>
  337. </div>
  338. </section>
  339. {% endcapture %}
  340. {% capture navbar_dropdown_item_active_example %}
  341. <nav class="navbar" role="navigation" aria-label="dropdown navigation">
  342. <a class="navbar-item">
  343. <img src="{{ site.url }}/images/bulma-logo.png" alt="{{ site.title }}" width="112" height="28">
  344. </a>
  345. <div class="navbar-item has-dropdown is-active">
  346. <a class="navbar-link">
  347. Docs
  348. </a>
  349. <div class="navbar-dropdown">
  350. <a class="navbar-item">
  351. Overview
  352. </a>
  353. <a class="navbar-item is-active">
  354. Elements
  355. </a>
  356. <a class="navbar-item">
  357. Components
  358. </a>
  359. <hr class="navbar-divider">
  360. <div class="navbar-item">
  361. Version {{ site.version }}
  362. </div>
  363. </div>
  364. </div>
  365. </nav>
  366. <section class="hero is-primary">
  367. <div class="hero-body">
  368. <p class="title">
  369. Documentation
  370. </p>
  371. <p class="subtitle">
  372. Everything you need to <strong>create a website</strong> with Bulma
  373. </p>
  374. </div>
  375. </section>
  376. {% endcapture %}
  377. {% capture navbar_divider_example %}
  378. <hr class="navbar-divider">
  379. {% endcapture %}
  380. {% capture navbar_js_html %}
  381. <button class="button navbar-burger" data-target="navMenu">
  382. <span></span>
  383. <span></span>
  384. <span></span>
  385. </button>
  386. <div class="navbar-menu" id="navMenu">
  387. <!-- navbar-start, navbar-end... -->
  388. </div>
  389. {% endcapture %}
  390. {% capture navbar_js_code %}
  391. document.addEventListener('DOMContentLoaded', function () {
  392. // Get all "navbar-burger" elements
  393. var $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);
  394. // Check if there are any navbar burgers
  395. if ($navbarBurgers.length > 0) {
  396. // Add a click event on each of them
  397. $navbarBurgers.forEach(function ($el) {
  398. $el.addEventListener('click', function () {
  399. // Get the target from the "data-target" attribute
  400. var target = $el.dataset.target;
  401. var $target = document.getElementById(target);
  402. // Toggle the class on both the "navbar-burger" and the "navbar-menu"
  403. $el.classList.toggle('is-active');
  404. $target.classList.toggle('is-active');
  405. });
  406. });
  407. }
  408. });
  409. {% endcapture %}
  410. {% capture navbar_color_markup %}
  411. <nav class="navbar is-primary">
  412. <!-- navbar brand, navbar menu... -->
  413. </nav>
  414. {% endcapture %}
  415. <section class="section">
  416. <div class="container">
  417. <h1 class="title">Navbar</h1>
  418. <h2 class="subtitle">
  419. A responsive horizontal <strong>navbar</strong> that can supports images, links, buttons, and dropdowns
  420. </h2>
  421. {%
  422. include meta.html
  423. new=true
  424. since="0.4.3"
  425. colors=true
  426. sizes=false
  427. variables=true
  428. %}
  429. <hr>
  430. <div class="message is-success">
  431. <div class="message-body">
  432. <p>The new <code>navbar</code> replaces the deprecated <code>nav</code> component, whose documentation you can still access temporarily <a href="{{ site.url }}/documentation/components/nav/">here</a>.</p>
  433. </div>
  434. </div>
  435. <div class="content">
  436. <p>
  437. The <code>navbar</code> component is a responsive and versatile horizontal navigation bar with the following structure:
  438. </p>
  439. <ul>
  440. <li>
  441. <code>navbar</code> the <strong>main</strong> container
  442. <ul>
  443. <li>
  444. <code>navbar-brand</code> the <strong>left side</strong>, <strong class="has-text-success">always visible</strong>, which usually contains the <strong>logo</strong> and optionally some links or icons
  445. <ul>
  446. <li>
  447. <code>navbar-burger</code> the <strong>hamburger</strong> icon, which toggles the navbar menu on touch devices
  448. </li>
  449. </ul>
  450. </li>
  451. <li>
  452. <code>navbar-menu</code> the <strong>right side</strong>, hidden on touch devices, visible on desktop
  453. <ul>
  454. <li>
  455. <code>navbar-start</code> the <strong>left part</strong> of the menu, which appears next to the navbar brand on desktop
  456. </li>
  457. <li>
  458. <code>navbar-end</code> the <strong>right part</strong> of the menu, which appears at the end of the navbar
  459. <ul>
  460. <li>
  461. <code>navbar-item</code> each <strong>single item</strong> of the navbar, which can either be an <code>a</code> or a <code>div</code>
  462. <ul>
  463. <li>
  464. <code>navbar-link</code> a <strong>link</strong> as the sibling of a dropdown, with an arrow
  465. </li>
  466. <li>
  467. <code>navbar-dropdown</code> the <strong>dropdown menu</strong>, which can include navbar items and dividers
  468. <ul>
  469. <li>
  470. <code>navbar-divider</code> a <strong>horizontal line</strong> to separate navbar items
  471. </li>
  472. </ul>
  473. </li>
  474. </ul>
  475. </li>
  476. </ul>
  477. </li>
  478. </ul>
  479. </li>
  480. </ul>
  481. </li>
  482. </ul>
  483. </div>
  484. {% include anchor.html name="Navbar brand" %}
  485. <div class="content">
  486. <p>
  487. The <code>navbar-brand</code> is the left side of the navbar. It can contain:
  488. </p>
  489. <ul>
  490. <li>
  491. a number of <code>navbar-item</code>
  492. </li>
  493. <li>
  494. the <code>navbar-burger</code> as last child
  495. </li>
  496. </ul>
  497. </div>
  498. {% highlight html %}{{navbar_brand_example}}{% endhighlight %}
  499. <div class="content">
  500. <p>
  501. The navbar brand is <strong>always visible</strong>: on both touch devices {% include bp/touch.html %} and desktop {% include bp/desktop.html %}. As a result, it is recommended to only use a few navbar items to avoid <strong>overflowing</strong> horizontally on small devices.
  502. </p>
  503. </div>
  504. <div class="bd-example is-paddingless">
  505. {{navbar_brand_items_example}}
  506. </div>
  507. {% highlight html %}{{navbar_brand_items_example}}{% endhighlight %}
  508. <div class="content">
  509. <p>
  510. On desktop {% include bp/desktop.html %}, the navbar brand will only take up the space it needs.
  511. </p>
  512. </div>
  513. {% include anchor.html name="Navbar burger" %}
  514. <div class="content">
  515. <p>
  516. The <code>navbar-burger</code> is a hamburger menu that only appears on <strong>mobile</strong>. It has to appear as the last child of <code>navbar-brand</code>.
  517. </p>
  518. </div>
  519. <div class="bd-example is-paddingless">
  520. <div class="navbar-burger" style="display: flex;">
  521. <span></span>
  522. <span></span>
  523. <span></span>
  524. </div>
  525. </div>
  526. {% highlight html %}{{ navbar_burger_example }}{% endhighlight %}
  527. <div class="content">
  528. <p>
  529. You can add the modifier class <code>is-active</code> to turn it into a cross.
  530. </p>
  531. </div>
  532. <div class="bd-example is-paddingless">
  533. <div class="navbar-burger is-active" style="display: flex;">
  534. <span></span>
  535. <span></span>
  536. <span></span>
  537. </div>
  538. </div>
  539. {% include anchor.html name="Navbar menu" %}
  540. <div class="content">
  541. <p>
  542. The <code>navbar-menu</code> is the <strong>counterpart</strong> of the navbar brand. As such, it must appear as a direct child of <code>navbar</code>, as a sibling of <code>navbar-brand</code>.
  543. </p>
  544. </div>
  545. {% highlight html %}{{navbar_menu_example}}{% endhighlight %}
  546. <div class="content">
  547. <p>
  548. The <code>navbar-menu</code> is <strong>hidden on touch devices</strong> {% include bp/touch.html %}. You need to add the modifier class <code>is-active</code> to display it.
  549. </p>
  550. </div>
  551. {% highlight html %}{{navbar_menu_active_example}}{% endhighlight %}
  552. <div class="content">
  553. <p>
  554. On desktop {% include bp/desktop.html %}, the <code>navbar-menu</code> will <strong>fill up the space</strong> available in the navbar, leaving the navbar brand just the space it needs. It needs, however, two elements as direct children:
  555. </p>
  556. <ul>
  557. <li>
  558. <code>navbar-start</code>
  559. </li>
  560. <li>
  561. <code>navbar-end</code>
  562. </li>
  563. </ul>
  564. </div>
  565. <hr>
  566. <div id="navbarJsExample" class="message is-info">
  567. <h4 class="message-header">Javascript toggle</h4>
  568. <div class="message-body">
  569. <div class="content">
  570. <p>
  571. The Bulma package <strong>does not come with any JavaScript</strong>.
  572. <br>
  573. Here is however an implementation example, which toggles the class <code>is-active</code> on both the <code>navbar-burger</code> and the targeted <code>navbar-menu</code>.
  574. </p>
  575. {% highlight html %}{{ navbar_js_html }}{% endhighlight %}
  576. {% highlight javascript %}{{ navbar_js_code }}{% endhighlight %}
  577. </div>
  578. </div>
  579. </div>
  580. {% include anchor.html name="Navbar start and navbar end" %}
  581. <div class="content">
  582. <p>
  583. The <code>navbar-start</code> and <code>navbar-end</code> are the two direct and only children of the <code>navbar-menu</code>.
  584. </p>
  585. <p>
  586. On desktop {% include bp/desktop.html %}:
  587. </p>
  588. <ul>
  589. <li>
  590. <code>navbar-start</code> will appear on the <strong>left</strong>
  591. </li>
  592. <li>
  593. <code>navbar-end</code> will appear on the <strong>right</strong>
  594. </li>
  595. </ul>
  596. <p>
  597. Each of them can contain any number of <code>navbar-item</code>.
  598. </p>
  599. </div>
  600. {% highlight html %}{{navbar_start_end_example}}{% endhighlight %}
  601. {% include anchor.html name="Navbar item" %}
  602. <div class="content">
  603. <p>
  604. A <code>navbar-item</code> is a repeatable element that can be:
  605. </p>
  606. <ul>
  607. <li>
  608. a navigation <strong>link</strong>
  609. {% highlight html %}{{ navbar_item_link_example }}{% endhighlight %}
  610. </li>
  611. <li>
  612. a container for the <strong>brand logo</strong>
  613. {% highlight html %}{{ navbar_item_brand_example }}{% endhighlight %}
  614. </li>
  615. <li>
  616. the <strong>parent</strong> of a dropdown menu
  617. {% highlight html %}{{ navbar_item_dropdown_example }}{% endhighlight %}
  618. </li>
  619. <li>
  620. a child of a <strong>navbar dropdown</strong>
  621. {% highlight html %}{{ navbar_item_dropdown_bis_example }}{% endhighlight %}
  622. </li>
  623. <li>
  624. a container for almost <strong>anything</strong> you want, like a <code>field</code>
  625. <div class="highlight-full">
  626. {% highlight html %}{{ navbar_item_other_example }}{% endhighlight %}
  627. </div>
  628. </li>
  629. </ul>
  630. <p>
  631. It can either be an anchor tag <code>&lt;a&gt;</code> or a <code>&lt;div&gt;</code>, as a <strong>direct child</strong> of either:
  632. </p>
  633. <ul>
  634. <li>
  635. <code>navbar</code>
  636. </li>
  637. <li>
  638. <code>navbar-brand</code>
  639. </li>
  640. <li>
  641. <code>navbar-start</code>
  642. </li>
  643. <li>
  644. <code>navbar-end</code>
  645. </li>
  646. <li>
  647. <code>navbar-dropdown</code>
  648. </li>
  649. </ul>
  650. <p>
  651. You can add the modifier class <code>is-expanded</code> to turn it into a full-width element.
  652. </p>
  653. </div>
  654. {% include anchor.html name="Transparent navbar" %}
  655. <div class="content">
  656. <p>
  657. To seamlessly integrate the navbar in any visual context, you can add the <code>is-transparent</code> modifier on the <code>navbar</code> component. This will remove any hover or active background from the navbar items.
  658. </p>
  659. </div>
  660. {% include snippet.html content=navbar_transparent_example paddingless=true horizontal=true more=true %}
  661. {% include anchor.html name="Fixed navbar" %}
  662. {% include elements/new-tag.html version="0.6.1" %}
  663. <div class="content">
  664. <p>
  665. You can now <strong>fix</strong> the navbar to either the <strong>top</strong> or <strong>bottom</strong> of the page. This is a 2-step process:
  666. </p>
  667. <ul>
  668. <li>
  669. Add either <code>is-fixed-top</code> or <code>is-fixed-bottom</code> to the <code>navbar</code> component
  670. {% highlight html %}<nav class="navbar is-fixed-top">{% endhighlight %}
  671. </li>
  672. <li>
  673. Add the corresponding <code>has-navbar-fixed-top</code> or <code>has-navbar-fixed-bottom</code> modifier to the <code>&lt;html&gt;</code> element to provide the appropriate padding to the page
  674. {% highlight html %}<html class="has-navbar-fixed-top">{% endhighlight %}
  675. </li>
  676. </ul>
  677. </div>
  678. <h4 class="title is-5">Try it out!</h4>
  679. <div id="navbarToggles" class="buttons">
  680. <a id="navbarFixTop" class="button is-link">
  681. <span class="icon">
  682. <i class="fa fa-square-o"></i>
  683. </span>
  684. <span>Fix top navbar</span>
  685. </a>
  686. <a id="navbarFixBottom" class="button is-link">
  687. <span class="icon">
  688. <i class="fa fa-square-o"></i>
  689. </span>
  690. <span>Show bottom navbar</span>
  691. </a>
  692. </div>
  693. {% include anchor.html name="Dropdown menu" %}
  694. <div class="content">
  695. <p>
  696. To create a <strong>dropdown menu</strong>, you will need <strong>4</strong> elements:
  697. </p>
  698. <ul>
  699. <li>
  700. <code>navbar-item</code> with the <code>has-dropdown</code> modifier
  701. </li>
  702. <li>
  703. <code>navbar-link</code> which contains the dropdown arrow
  704. </li>
  705. <li>
  706. <code>navbar-dropdown</code> which can contain instances of <code>navbar-item</code> and <code>navbar-divider</code>
  707. </li>
  708. </ul>
  709. </div>
  710. <div class="columns">
  711. <div class="column">
  712. <div class="bd-example is-paddingless">
  713. {{ navbar_dropdown_example }}
  714. </div>
  715. </div>
  716. <div class="column">
  717. {% highlight html %}{{ navbar_dropdown_example }}{% endhighlight %}
  718. </div>
  719. </div>
  720. <h4 class="title is-4">
  721. Show/hide the dropdown with either <strong>CSS</strong> or <strong>JavaScript</strong>
  722. </h4>
  723. <div class="content">
  724. <p>
  725. The <code>navbar-dropdown</code> is visible on touch devices {% include bp/touch.html %} but hidden on desktop {% include bp/desktop.html %}. <em>How</em> the dropdown is displayed on desktop depends on the parent's class.
  726. </p>
  727. <p>
  728. The <code>navbar-item</code> with the <code>has-dropdown</code> modifier, has <strong>2 additional modifiers</strong>
  729. </p>
  730. <ul>
  731. <li>
  732. <code>is-hoverable</code>: the dropdown will show up when <strong>hovering</strong> the parent <code>navbar-item</code>
  733. </li>
  734. <li>
  735. <code>is-active</code>: the dropdown will show up <strong>all the time</strong>
  736. </li>
  737. </ul>
  738. </div>
  739. <div class="message is-success">
  740. <p class="message-body">
  741. While the CSS <code>:hover</code> implementation works perfectly, the <code>is-active</code> class is available for users who want to control the display of the dropdown with <strong>JavaScript</strong>.
  742. </p>
  743. </div>
  744. {% highlight html %}{{ navbar_dropdown_hover_snippet }}{% endhighlight %}
  745. <div class="columns">
  746. <div class="column">
  747. <div class="bd-example is-paddingless">
  748. {{ navbar_dropdown_hover_example }}
  749. </div>
  750. </div>
  751. <div class="column">
  752. {% highlight html %}{{ navbar_dropdown_hover_example }}{% endhighlight %}
  753. </div>
  754. </div>
  755. {% highlight html %}{{ navbar_dropdown_active_snippet }}{% endhighlight %}
  756. <div class="columns">
  757. <div class="column">
  758. <div class="bd-example is-paddingless">
  759. {{ navbar_dropdown_active_example }}
  760. </div>
  761. </div>
  762. <div class="column">
  763. {% highlight html %}{{ navbar_dropdown_active_example }}{% endhighlight %}
  764. </div>
  765. </div>
  766. <h4 class="title is-4">
  767. Right dropdown
  768. <span class="tag is-info">0.5.1</span>
  769. </h4>
  770. <div class="content">
  771. <p>
  772. If your parent <code>navbar-item</code> is on the right side, you can position the dropdown to start from the <strong>right</strong> with the <code>is-right</code> modifier.
  773. </p>
  774. </div>
  775. {% highlight html %}{{ navbar_dropdown_right_snippet }}{% endhighlight %}
  776. <div class="columns">
  777. <div class="column">
  778. <div class="bd-example is-paddingless">
  779. {{ navbar_dropdown_right_example }}
  780. </div>
  781. </div>
  782. <div class="column">
  783. {% highlight html %}{{ navbar_dropdown_right_example }}{% endhighlight %}
  784. </div>
  785. </div>
  786. <h4 class="title is-4">
  787. Styles for the dropdown menu
  788. </h4>
  789. <div class="content">
  790. <p>
  791. By default, the <code>navbar-dropdown</code> has:
  792. </p>
  793. <ul>
  794. <li>
  795. a grey <code>border-top</code>
  796. </li>
  797. <li>
  798. a <code>border-radius</code> at both bottom corners
  799. </li>
  800. </ul>
  801. </div>
  802. <div class="columns">
  803. <div class="column">
  804. <div class="bd-example is-paddingless">
  805. {{ navbar_dropdown_default_example }}
  806. </div>
  807. </div>
  808. <div class="column">
  809. {% highlight html %}{{ navbar_dropdown_default_example }}{% endhighlight %}
  810. </div>
  811. </div>
  812. <div class="content">
  813. <p>
  814. When having a <a href="#transparent-navbar">transparent navbar</a>, it is preferable to use the boxed version of the dropdown, by using the <code>is-boxed</code> modifier.
  815. </p>
  816. <ul>
  817. <li>
  818. the grey border is <strong>removed</strong>
  819. </li>
  820. <li>
  821. a slight <strong>inner shadow</strong> is added
  822. </li>
  823. <li>
  824. all corners are <strong>rounded</strong>
  825. </li>
  826. <li>
  827. the hover/active state is <strong>animated</strong>
  828. </li>
  829. </ul>
  830. </div>
  831. <div class="columns">
  832. <div class="column">
  833. <div class="bd-example is-paddingless">
  834. {{ navbar_dropdown_boxed_example }}
  835. </div>
  836. </div>
  837. <div class="column">
  838. {% highlight html %}{{ navbar_dropdown_boxed_example }}{% endhighlight %}
  839. </div>
  840. </div>
  841. <h4 class="title is-4">
  842. Active dropdown navbar item
  843. </h4>
  844. <div class="columns">
  845. <div class="column">
  846. <div class="bd-example is-paddingless">
  847. {{ navbar_dropdown_item_active_example }}
  848. </div>
  849. </div>
  850. <div class="column">
  851. {% highlight html %}{{ navbar_dropdown_item_active_example }}{% endhighlight %}
  852. </div>
  853. </div>
  854. <h4 class="title is-4">
  855. Dropdown divider
  856. </h4>
  857. <div class="content">
  858. <p>
  859. You can add a <code>navbar-divider</code> to display a <strong>horizontal rule</strong> in a <code>navbar-dropdown</code>.
  860. </p>
  861. </div>
  862. {% highlight html %}{{ navbar_divider_example }}{% endhighlight %}
  863. {% include anchor.html name="Colors" %}
  864. <div class="tags has-addons">
  865. <span class="tag">New!</span>
  866. <span class="tag is-info">0.5.2</span>
  867. </div>
  868. <div class="content">
  869. <p>
  870. You can change the background color of the <code>navbar</code> by using one of the <strong>9 color modifiers:</strong>
  871. </p>
  872. <ul>
  873. <li><code>is-primary</code></li>
  874. <li><code>is-link</code></li>
  875. <li><code>is-info</code></li>
  876. <li><code>is-success</code></li>
  877. <li><code>is-warning</code></li>
  878. <li><code>is-danger</code></li>
  879. <li><code>is-black</code></li>
  880. <li><code>is-dark</code></li>
  881. <li><code>is-light</code></li>
  882. <li><code>is-white</code></li>
  883. </ul>
  884. </div>
  885. {% highlight html %}{{ navbar_color_markup }}{% endhighlight %}
  886. <div class="bd-example is-paddingless">
  887. {% include examples/navbar-color.html color="primary" %}
  888. </div>
  889. <div class="bd-example is-paddingless">
  890. {% include examples/navbar-color.html color="link" %}
  891. </div>
  892. <div class="bd-example is-paddingless">
  893. {% include examples/navbar-color.html color="info" %}
  894. </div>
  895. <div class="bd-example is-paddingless">
  896. {% include examples/navbar-color.html color="success" %}
  897. </div>
  898. <div class="bd-example is-paddingless">
  899. {% include examples/navbar-color.html color="warning" light=true %}
  900. </div>
  901. <div class="bd-example is-paddingless">
  902. {% include examples/navbar-color.html color="danger" %}
  903. </div>
  904. <div class="bd-example is-paddingless">
  905. {% include examples/navbar-color.html color="black" %}
  906. </div>
  907. <div class="bd-example is-paddingless">
  908. {% include examples/navbar-color.html color="dark" %}
  909. </div>
  910. <div class="bd-example is-paddingless">
  911. {% include examples/navbar-color.html color="light" light=true %}
  912. </div>
  913. <div class="bd-example is-paddingless">
  914. {% include examples/navbar-color.html color="white" light=true %}
  915. </div>
  916. {% include variables.html type='component' %}
  917. </div>
  918. </section>