navbar.html 32 KB

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