navbar.html 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135
  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_dropup_snippet %}
  267. <div class="navbar-item has-dropdown has-dropdown-up is-hoverable">
  268. <a class="navbar-link" href="/documentation/overview/start/">
  269. Docs
  270. </a>
  271. <div class="navbar-dropdown">
  272. <a class="navbar-item" href="/documentation/overview/start/">
  273. Overview
  274. </a>
  275. </div>
  276. </div>
  277. {% endcapture %}
  278. {% capture navbar_dropup_example %}
  279. <section class="hero is-primary">
  280. <div class="hero-body">
  281. <p class="title">
  282. Documentation
  283. </p>
  284. <p class="subtitle">
  285. Everything you need to <strong>create a website</strong> with Bulma
  286. </p>
  287. </div>
  288. </section>
  289. <nav class="navbar" role="navigation" aria-label="dropdown navigation">
  290. <div class="navbar-menu">
  291. <div class="navbar-start">
  292. <div class="navbar-item has-dropdown has-dropdown-up is-active">
  293. <a class="navbar-link">
  294. Dropup
  295. </a>
  296. <div class="navbar-dropdown">
  297. <a class="navbar-item">
  298. Overview
  299. </a>
  300. <a class="navbar-item">
  301. Elements
  302. </a>
  303. <a class="navbar-item">
  304. Components
  305. </a>
  306. <hr class="navbar-divider">
  307. <div class="navbar-item">
  308. Version {{ site.version }}
  309. </div>
  310. </div>
  311. </div>
  312. </div>
  313. </div>
  314. </nav>
  315. {% endcapture %}
  316. {% capture navbar_dropdown_default_example %}
  317. <nav class="navbar" role="navigation" aria-label="dropdown navigation">
  318. <a class="navbar-item">
  319. <img src="{{ site.url }}/images/bulma-logo.png" alt="{{ site.title }}" width="112" height="28">
  320. </a>
  321. <div class="navbar-item has-dropdown is-active">
  322. <a class="navbar-link">
  323. Docs
  324. </a>
  325. <div class="navbar-dropdown">
  326. <a class="navbar-item">
  327. Overview
  328. </a>
  329. <a class="navbar-item">
  330. Elements
  331. </a>
  332. <a class="navbar-item">
  333. Components
  334. </a>
  335. <hr class="navbar-divider">
  336. <div class="navbar-item">
  337. Version {{ site.version }}
  338. </div>
  339. </div>
  340. </div>
  341. </nav>
  342. <section class="hero is-primary">
  343. <div class="hero-body">
  344. <p class="title">
  345. Documentation
  346. </p>
  347. <p class="subtitle">
  348. Everything you need to <strong>create a website</strong> with Bulma
  349. </p>
  350. </div>
  351. </section>
  352. {% endcapture %}
  353. {% capture navbar_dropdown_boxed_example %}
  354. <nav class="navbar is-transparent" role="navigation" aria-label="dropdown navigation">
  355. <a class="navbar-item">
  356. <img src="{{ site.url }}/images/bulma-logo.png" alt="{{ site.title }}" width="112" height="28">
  357. </a>
  358. <div class="navbar-item has-dropdown is-active">
  359. <a class="navbar-link">
  360. Docs
  361. </a>
  362. <div class="navbar-dropdown is-boxed">
  363. <a class="navbar-item">
  364. Overview
  365. </a>
  366. <a class="navbar-item">
  367. Elements
  368. </a>
  369. <a class="navbar-item">
  370. Components
  371. </a>
  372. <hr class="navbar-divider">
  373. <div class="navbar-item">
  374. Version {{ site.version }}
  375. </div>
  376. </div>
  377. </div>
  378. </nav>
  379. <section class="hero">
  380. <div class="hero-body">
  381. <p class="title">
  382. Documentation
  383. </p>
  384. <p class="subtitle">
  385. Everything you need to <strong>create a website</strong> with Bulma
  386. </p>
  387. </div>
  388. </section>
  389. {% endcapture %}
  390. {% capture navbar_dropdown_item_active_example %}
  391. <nav class="navbar" role="navigation" aria-label="dropdown navigation">
  392. <a class="navbar-item">
  393. <img src="{{ site.url }}/images/bulma-logo.png" alt="{{ site.title }}" width="112" height="28">
  394. </a>
  395. <div class="navbar-item has-dropdown is-active">
  396. <a class="navbar-link">
  397. Docs
  398. </a>
  399. <div class="navbar-dropdown">
  400. <a class="navbar-item">
  401. Overview
  402. </a>
  403. <a class="navbar-item is-active">
  404. Elements
  405. </a>
  406. <a class="navbar-item">
  407. Components
  408. </a>
  409. <hr class="navbar-divider">
  410. <div class="navbar-item">
  411. Version {{ site.version }}
  412. </div>
  413. </div>
  414. </div>
  415. </nav>
  416. <section class="hero is-primary">
  417. <div class="hero-body">
  418. <p class="title">
  419. Documentation
  420. </p>
  421. <p class="subtitle">
  422. Everything you need to <strong>create a website</strong> with Bulma
  423. </p>
  424. </div>
  425. </section>
  426. {% endcapture %}
  427. {% capture navbar_divider_example %}
  428. <hr class="navbar-divider">
  429. {% endcapture %}
  430. {% capture navbar_js_html %}
  431. <button class="button navbar-burger" data-target="navMenu">
  432. <span></span>
  433. <span></span>
  434. <span></span>
  435. </button>
  436. <div class="navbar-menu" id="navMenu">
  437. <!-- navbar-start, navbar-end... -->
  438. </div>
  439. {% endcapture %}
  440. {% capture navbar_js_code %}
  441. document.addEventListener('DOMContentLoaded', function () {
  442. // Get all "navbar-burger" elements
  443. var $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);
  444. // Check if there are any navbar burgers
  445. if ($navbarBurgers.length > 0) {
  446. // Add a click event on each of them
  447. $navbarBurgers.forEach(function ($el) {
  448. $el.addEventListener('click', function () {
  449. // Get the target from the "data-target" attribute
  450. var target = $el.dataset.target;
  451. var $target = document.getElementById(target);
  452. // Toggle the class on both the "navbar-burger" and the "navbar-menu"
  453. $el.classList.toggle('is-active');
  454. $target.classList.toggle('is-active');
  455. });
  456. });
  457. }
  458. });
  459. {% endcapture %}
  460. {% capture navbar_color_markup %}
  461. <nav class="navbar is-primary">
  462. <!-- navbar brand, navbar menu... -->
  463. </nav>
  464. {% endcapture %}
  465. <section class="section">
  466. <div class="container">
  467. <h1 class="title">Navbar</h1>
  468. <h2 class="subtitle">
  469. A responsive horizontal <strong>navbar</strong> that can support images, links, buttons, and dropdowns
  470. </h2>
  471. {%
  472. include meta.html
  473. new=true
  474. since="0.4.3"
  475. colors=true
  476. sizes=false
  477. variables=true
  478. %}
  479. <hr>
  480. <div class="message is-success">
  481. <div class="message-body">
  482. <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>
  483. </div>
  484. </div>
  485. <div class="content">
  486. <p>
  487. The <code>navbar</code> component is a responsive and versatile horizontal navigation bar with the following structure:
  488. </p>
  489. <ul>
  490. <li>
  491. <code>navbar</code> the <strong>main</strong> container
  492. <ul>
  493. <li>
  494. <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
  495. <ul>
  496. <li>
  497. <code>navbar-burger</code> the <strong>hamburger</strong> icon, which toggles the navbar menu on touch devices
  498. </li>
  499. </ul>
  500. </li>
  501. <li>
  502. <code>navbar-menu</code> the <strong>right side</strong>, hidden on touch devices, visible on desktop
  503. <ul>
  504. <li>
  505. <code>navbar-start</code> the <strong>left part</strong> of the menu, which appears next to the navbar brand on desktop
  506. </li>
  507. <li>
  508. <code>navbar-end</code> the <strong>right part</strong> of the menu, which appears at the end of the navbar
  509. <ul>
  510. <li>
  511. <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>
  512. <ul>
  513. <li>
  514. <code>navbar-link</code> a <strong>link</strong> as the sibling of a dropdown, with an arrow
  515. </li>
  516. <li>
  517. <code>navbar-dropdown</code> the <strong>dropdown menu</strong>, which can include navbar items and dividers
  518. <ul>
  519. <li>
  520. <code>navbar-divider</code> a <strong>horizontal line</strong> to separate navbar items
  521. </li>
  522. </ul>
  523. </li>
  524. </ul>
  525. </li>
  526. </ul>
  527. </li>
  528. </ul>
  529. </li>
  530. </ul>
  531. </li>
  532. </ul>
  533. </div>
  534. {% include anchor.html name="Navbar brand" %}
  535. <div class="content">
  536. <p>
  537. The <code>navbar-brand</code> is the left side of the navbar. It can contain:
  538. </p>
  539. <ul>
  540. <li>
  541. a number of <code>navbar-item</code>
  542. </li>
  543. <li>
  544. the <code>navbar-burger</code> as last child
  545. </li>
  546. </ul>
  547. </div>
  548. {% highlight html %}{{navbar_brand_example}}{% endhighlight %}
  549. <div class="content">
  550. <p>
  551. 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.
  552. </p>
  553. </div>
  554. <div class="bd-example is-paddingless">
  555. {{navbar_brand_items_example}}
  556. </div>
  557. {% highlight html %}{{navbar_brand_items_example}}{% endhighlight %}
  558. <div class="content">
  559. <p>
  560. On desktop {% include bp/desktop.html %}, the navbar brand will only take up the space it needs.
  561. </p>
  562. </div>
  563. {% include anchor.html name="Navbar burger" %}
  564. <div class="content">
  565. <p>
  566. 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>.
  567. </p>
  568. </div>
  569. <div class="bd-example is-paddingless">
  570. <div class="navbar-burger" style="display: flex;">
  571. <span></span>
  572. <span></span>
  573. <span></span>
  574. </div>
  575. </div>
  576. {% highlight html %}{{ navbar_burger_example }}{% endhighlight %}
  577. <div class="content">
  578. <p>
  579. You can add the modifier class <code>is-active</code> to turn it into a cross.
  580. </p>
  581. </div>
  582. <div class="bd-example is-paddingless">
  583. <div class="navbar-burger is-active" style="display: flex;">
  584. <span></span>
  585. <span></span>
  586. <span></span>
  587. </div>
  588. </div>
  589. {% include anchor.html name="Navbar menu" %}
  590. <div class="content">
  591. <p>
  592. 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>.
  593. </p>
  594. </div>
  595. {% highlight html %}{{navbar_menu_example}}{% endhighlight %}
  596. <div class="content">
  597. <p>
  598. 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.
  599. </p>
  600. </div>
  601. {% highlight html %}{{navbar_menu_active_example}}{% endhighlight %}
  602. <div class="content">
  603. <p>
  604. 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:
  605. </p>
  606. <ul>
  607. <li>
  608. <code>navbar-start</code>
  609. </li>
  610. <li>
  611. <code>navbar-end</code>
  612. </li>
  613. </ul>
  614. </div>
  615. <hr>
  616. <div id="navbarJsExample" class="message is-info">
  617. <h4 class="message-header">Javascript toggle</h4>
  618. <div class="message-body">
  619. <div class="content">
  620. <p>
  621. The Bulma package <strong>does not come with any JavaScript</strong>.
  622. <br>
  623. 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>.
  624. </p>
  625. {% highlight html %}{{ navbar_js_html }}{% endhighlight %}
  626. {% highlight javascript %}{{ navbar_js_code }}{% endhighlight %}
  627. </div>
  628. </div>
  629. </div>
  630. {% include anchor.html name="Navbar start and navbar end" %}
  631. <div class="content">
  632. <p>
  633. The <code>navbar-start</code> and <code>navbar-end</code> are the two direct and only children of the <code>navbar-menu</code>.
  634. </p>
  635. <p>
  636. On desktop {% include bp/desktop.html %}:
  637. </p>
  638. <ul>
  639. <li>
  640. <code>navbar-start</code> will appear on the <strong>left</strong>
  641. </li>
  642. <li>
  643. <code>navbar-end</code> will appear on the <strong>right</strong>
  644. </li>
  645. </ul>
  646. <p>
  647. Each of them can contain any number of <code>navbar-item</code>.
  648. </p>
  649. </div>
  650. {% highlight html %}{{navbar_start_end_example}}{% endhighlight %}
  651. {% include anchor.html name="Navbar item" %}
  652. <div class="content">
  653. <p>
  654. A <code>navbar-item</code> is a repeatable element that can be:
  655. </p>
  656. <ul class="bd-spaced">
  657. <li>
  658. a navigation <strong>link</strong>
  659. {% highlight html %}{{ navbar_item_link_example }}{% endhighlight %}
  660. </li>
  661. <li>
  662. a container for the <strong>brand logo</strong>
  663. {% highlight html %}{{ navbar_item_brand_example }}{% endhighlight %}
  664. </li>
  665. <li>
  666. the <strong>parent</strong> of a dropdown menu
  667. {% highlight html %}{{ navbar_item_dropdown_example }}{% endhighlight %}
  668. </li>
  669. <li>
  670. a child of a <strong>navbar dropdown</strong>
  671. {% highlight html %}{{ navbar_item_dropdown_bis_example }}{% endhighlight %}
  672. </li>
  673. <li>
  674. a container for almost <strong>anything</strong> you want, like a <code>field</code>
  675. <div class="highlight-full">
  676. {% highlight html %}{{ navbar_item_other_example }}{% endhighlight %}
  677. </div>
  678. </li>
  679. </ul>
  680. <p>
  681. 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:
  682. </p>
  683. <ul>
  684. <li>
  685. <code>navbar</code>
  686. </li>
  687. <li>
  688. <code>navbar-brand</code>
  689. </li>
  690. <li>
  691. <code>navbar-start</code>
  692. </li>
  693. <li>
  694. <code>navbar-end</code>
  695. </li>
  696. <li>
  697. <code>navbar-dropdown</code>
  698. </li>
  699. </ul>
  700. <p>
  701. You can add the modifier class <code>is-expanded</code> to turn it into a full-width element.
  702. </p>
  703. </div>
  704. {% include anchor.html name="Transparent navbar" %}
  705. <div class="content">
  706. <p>
  707. 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.
  708. </p>
  709. </div>
  710. {% include snippet.html content=navbar_transparent_example paddingless=true horizontal=true more=true %}
  711. {% include anchor.html name="Fixed navbar" %}
  712. {% include elements/new-tag.html version="0.6.1" %}
  713. <div class="content">
  714. <p>
  715. 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:
  716. </p>
  717. <ul class="bd-spaced">
  718. <li>
  719. Add either <code>is-fixed-top</code> or <code>is-fixed-bottom</code> to the <code>navbar</code> component
  720. {% highlight html %}<nav class="navbar is-fixed-top">{% endhighlight %}
  721. </li>
  722. <li>
  723. 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
  724. {% highlight html %}<html class="has-navbar-fixed-top">{% endhighlight %}
  725. </li>
  726. </ul>
  727. </div>
  728. <h4 class="title is-5">Try it out!</h4>
  729. <div id="navbarToggles" class="buttons">
  730. <a id="navbarFixBottom" class="button is-link">
  731. <span class="icon">
  732. <i class="fa fa-square-o"></i>
  733. </span>
  734. <span>Show <strong>bottom</strong> navbar</span>
  735. </a>
  736. </div>
  737. {% include anchor.html name="Dropdown menu" %}
  738. <div class="content">
  739. <p>
  740. To create a <strong>dropdown menu</strong>, you will need <strong>4</strong> elements:
  741. </p>
  742. <ul>
  743. <li>
  744. <code>navbar-item</code> with the <code>has-dropdown</code> modifier
  745. </li>
  746. <li>
  747. <code>navbar-link</code> which contains the dropdown arrow
  748. </li>
  749. <li>
  750. <code>navbar-dropdown</code> which can contain instances of <code>navbar-item</code> and <code>navbar-divider</code>
  751. </li>
  752. </ul>
  753. </div>
  754. <div class="columns">
  755. <div class="column">
  756. <div class="bd-example is-paddingless">
  757. {{ navbar_dropdown_example }}
  758. </div>
  759. </div>
  760. <div class="column">
  761. {% highlight html %}{{ navbar_dropdown_example }}{% endhighlight %}
  762. </div>
  763. </div>
  764. <h4 class="title is-4">
  765. Show/hide the dropdown with either <strong>CSS</strong> or <strong>JavaScript</strong>
  766. </h4>
  767. <div class="content">
  768. <p>
  769. 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.
  770. </p>
  771. <p>
  772. The <code>navbar-item</code> with the <code>has-dropdown</code> modifier, has <strong>2 additional modifiers</strong>
  773. </p>
  774. <ul>
  775. <li>
  776. <code>is-hoverable</code>: the dropdown will show up when <strong>hovering</strong> the parent <code>navbar-item</code>
  777. </li>
  778. <li>
  779. <code>is-active</code>: the dropdown will show up <strong>all the time</strong>
  780. </li>
  781. </ul>
  782. </div>
  783. <div class="message is-success">
  784. <p class="message-body">
  785. 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>.
  786. </p>
  787. </div>
  788. {% highlight html %}{{ navbar_dropdown_hover_snippet }}{% endhighlight %}
  789. <div class="columns">
  790. <div class="column">
  791. <div class="bd-example is-paddingless">
  792. {{ navbar_dropdown_hover_example }}
  793. </div>
  794. </div>
  795. <div class="column">
  796. {% highlight html %}{{ navbar_dropdown_hover_example }}{% endhighlight %}
  797. </div>
  798. </div>
  799. {% highlight html %}{{ navbar_dropdown_active_snippet }}{% endhighlight %}
  800. <div class="columns">
  801. <div class="column">
  802. <div class="bd-example is-paddingless">
  803. {{ navbar_dropdown_active_example }}
  804. </div>
  805. </div>
  806. <div class="column">
  807. {% highlight html %}{{ navbar_dropdown_active_example }}{% endhighlight %}
  808. </div>
  809. </div>
  810. <h4 class="title is-4">
  811. Right dropdown
  812. </h4>
  813. <div class="content">
  814. <p>
  815. 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.
  816. </p>
  817. </div>
  818. {% highlight html %}{{ navbar_dropdown_right_snippet }}{% endhighlight %}
  819. <div class="columns">
  820. <div class="column">
  821. <div class="bd-example is-paddingless">
  822. {{ navbar_dropdown_right_example }}
  823. </div>
  824. </div>
  825. <div class="column">
  826. {% highlight html %}{{ navbar_dropdown_right_example }}{% endhighlight %}
  827. </div>
  828. </div>
  829. <h4 class="title is-4">
  830. Dropup
  831. </h4>
  832. {% include elements/new-tag.html version="0.6.1" %}
  833. <div class="content">
  834. <p>
  835. If you're using a navbar at the bottom, like the <a href="#fixed-navbar">fixed bottom navbar</a>, you might want to use a <strong>dropup menu</strong>. Simply add the <code>has-dropdown</code> and <code>has-dropdown-up</code> modifiers to the parent <code>navbar-item</code>.
  836. </p>
  837. </div>
  838. {% highlight html %}{{ navbar_dropup_snippet }}{% endhighlight %}
  839. <div class="columns">
  840. <div class="column">
  841. <div class="bd-example is-paddingless">
  842. {{ navbar_dropup_example }}
  843. </div>
  844. </div>
  845. <div class="column">
  846. {% highlight html %}{{ navbar_dropup_example }}{% endhighlight %}
  847. </div>
  848. </div>
  849. <h4 class="title is-4">
  850. Styles for the dropdown menu
  851. </h4>
  852. <div class="content">
  853. <p>
  854. By default, the <code>navbar-dropdown</code> has:
  855. </p>
  856. <ul>
  857. <li>
  858. a grey <code>border-top</code>
  859. </li>
  860. <li>
  861. a <code>border-radius</code> at both bottom corners
  862. </li>
  863. </ul>
  864. </div>
  865. <div class="columns">
  866. <div class="column">
  867. <div class="bd-example is-paddingless">
  868. {{ navbar_dropdown_default_example }}
  869. </div>
  870. </div>
  871. <div class="column">
  872. {% highlight html %}{{ navbar_dropdown_default_example }}{% endhighlight %}
  873. </div>
  874. </div>
  875. <div class="content">
  876. <p>
  877. 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.
  878. </p>
  879. <ul>
  880. <li>
  881. the grey border is <strong>removed</strong>
  882. </li>
  883. <li>
  884. a slight <strong>inner shadow</strong> is added
  885. </li>
  886. <li>
  887. all corners are <strong>rounded</strong>
  888. </li>
  889. <li>
  890. the hover/active state is <strong>animated</strong>
  891. </li>
  892. </ul>
  893. </div>
  894. <div class="columns">
  895. <div class="column">
  896. <div class="bd-example is-paddingless">
  897. {{ navbar_dropdown_boxed_example }}
  898. </div>
  899. </div>
  900. <div class="column">
  901. {% highlight html %}{{ navbar_dropdown_boxed_example }}{% endhighlight %}
  902. </div>
  903. </div>
  904. <h4 class="title is-4">
  905. Active dropdown navbar item
  906. </h4>
  907. <div class="columns">
  908. <div class="column">
  909. <div class="bd-example is-paddingless">
  910. {{ navbar_dropdown_item_active_example }}
  911. </div>
  912. </div>
  913. <div class="column">
  914. {% highlight html %}{{ navbar_dropdown_item_active_example }}{% endhighlight %}
  915. </div>
  916. </div>
  917. <h4 class="title is-4">
  918. Dropdown divider
  919. </h4>
  920. <div class="content">
  921. <p>
  922. You can add a <code>navbar-divider</code> to display a <strong>horizontal rule</strong> in a <code>navbar-dropdown</code>.
  923. </p>
  924. </div>
  925. {% highlight html %}{{ navbar_divider_example }}{% endhighlight %}
  926. {% include anchor.html name="Colors" %}
  927. <div class="tags has-addons">
  928. <span class="tag">New!</span>
  929. <span class="tag is-info">0.5.2</span>
  930. </div>
  931. <div class="content">
  932. <p>
  933. You can change the background color of the <code>navbar</code> by using one of the <strong>9 color modifiers:</strong>
  934. </p>
  935. <ul>
  936. <li><code>is-primary</code></li>
  937. <li><code>is-link</code></li>
  938. <li><code>is-info</code></li>
  939. <li><code>is-success</code></li>
  940. <li><code>is-warning</code></li>
  941. <li><code>is-danger</code></li>
  942. <li><code>is-black</code></li>
  943. <li><code>is-dark</code></li>
  944. <li><code>is-light</code></li>
  945. <li><code>is-white</code></li>
  946. </ul>
  947. </div>
  948. {% highlight html %}{{ navbar_color_markup }}{% endhighlight %}
  949. <div class="bd-example is-paddingless">
  950. {% include examples/navbar-color.html color="primary" %}
  951. </div>
  952. <div class="bd-example is-paddingless">
  953. {% include examples/navbar-color.html color="link" %}
  954. </div>
  955. <div class="bd-example is-paddingless">
  956. {% include examples/navbar-color.html color="info" %}
  957. </div>
  958. <div class="bd-example is-paddingless">
  959. {% include examples/navbar-color.html color="success" %}
  960. </div>
  961. <div class="bd-example is-paddingless">
  962. {% include examples/navbar-color.html color="warning" light=true %}
  963. </div>
  964. <div class="bd-example is-paddingless">
  965. {% include examples/navbar-color.html color="danger" %}
  966. </div>
  967. <div class="bd-example is-paddingless">
  968. {% include examples/navbar-color.html color="black" %}
  969. </div>
  970. <div class="bd-example is-paddingless">
  971. {% include examples/navbar-color.html color="dark" %}
  972. </div>
  973. <div class="bd-example is-paddingless">
  974. {% include examples/navbar-color.html color="light" light=true %}
  975. </div>
  976. <div class="bd-example is-paddingless">
  977. {% include examples/navbar-color.html color="white" light=true %}
  978. </div>
  979. {% include variables.html type='component' %}
  980. </div>
  981. </section>