navbar.html 30 KB

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