navbar.html 28 KB

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