navbar.html 32 KB

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