navbar.html 27 KB

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