navbar.html 29 KB

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