navbar.html 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073
  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" role="navigation" aria-label="main navigation">
  67. <div class="navbar-brand">
  68. <!-- navbar items, navbar burger... -->
  69. </div>
  70. </nav>
  71. {% endcapture %}
  72. {% capture navbar_burger_example %}
  73. <button class="button navbar-burger">
  74. <span></span>
  75. <span></span>
  76. <span></span>
  77. </button>
  78. {% endcapture %}
  79. {% capture navbar_brand_items_example %}
  80. <nav class="navbar" role="navigation" aria-label="main navigation">
  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. <button class="button navbar-burger">
  86. <span></span>
  87. <span></span>
  88. <span></span>
  89. </button>
  90. </div>
  91. </nav>
  92. {% endcapture %}
  93. {% capture navbar_menu_example %}
  94. <nav class="navbar" role="navigation" aria-label="main navigation">
  95. <div class="navbar-brand">
  96. <!-- navbar items, navbar 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" alt="Bulma">
  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" aria-hidden="true"></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" aria-hidden="true"></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" role="navigation" aria-label="dropdown navigation">
  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" role="navigation" aria-label="dropdown navigation">
  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" role="navigation" aria-label="dropdown navigation">
  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" role="navigation" aria-label="dropdown navigation">
  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" role="navigation" aria-label="dropdown navigation">
  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" role="navigation" aria-label="dropdown navigation">
  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" role="navigation" aria-label="dropdown navigation">
  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. <button class="button navbar-burger" data-target="navMenu">
  436. <span></span>
  437. <span></span>
  438. <span></span>
  439. </button>
  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 navbar 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. {% capture navbar_color_markup %}
  465. <nav class="navbar is-primary">
  466. <!-- navbar brand, navbar menu... -->
  467. </nav>
  468. {% endcapture %}
  469. <section class="section">
  470. <div class="container">
  471. <h1 class="title">Navbar</h1>
  472. <h2 class="subtitle">
  473. A responsive horizontal <strong>navbar</strong> that can supports images, links, buttons, and dropdowns
  474. </h2>
  475. {%
  476. include meta.html
  477. new=true
  478. since="0.4.3"
  479. colors=true
  480. sizes=false
  481. variables=true
  482. %}
  483. <hr>
  484. <div class="message is-success">
  485. <div class="message-body">
  486. <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>
  487. </div>
  488. </div>
  489. <div class="content">
  490. <p>
  491. The <code>navbar</code> component is a responsive and versatile horizontal navigation bar with the following structure:
  492. </p>
  493. <ul>
  494. <li>
  495. <code>navbar</code> the <strong>main</strong> container
  496. <ul>
  497. <li>
  498. <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
  499. <ul>
  500. <li>
  501. <code>navbar-burger</code> the <strong>hamburger</strong> icon, which toggles the navbar menu on touch devices
  502. </li>
  503. </ul>
  504. </li>
  505. <li>
  506. <code>navbar-menu</code> the <strong>right side</strong>, hidden on touch devices, visible on desktop
  507. <ul>
  508. <li>
  509. <code>navbar-start</code> the <strong>left part</strong> of the menu, which appears next to the navbar brand on desktop
  510. </li>
  511. <li>
  512. <code>navbar-end</code> the <strong>right part</strong> of the menu, which appears at the end of the navbar
  513. <ul>
  514. <li>
  515. <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>
  516. <ul>
  517. <li>
  518. <code>navbar-link</code> a <strong>link</strong> as the sibling of a dropdown, with an arrow
  519. </li>
  520. <li>
  521. <code>navbar-dropdown</code> the <strong>dropdown menu</strong>, which can include navbar items and dividers
  522. <ul>
  523. <li>
  524. <code>navbar-divider</code> a <strong>horizontal line</strong> to separate navbar items
  525. </li>
  526. </ul>
  527. </li>
  528. </ul>
  529. </li>
  530. </ul>
  531. </li>
  532. </ul>
  533. </li>
  534. </ul>
  535. </li>
  536. </ul>
  537. </div>
  538. {% include anchor.html name="Navbar brand" %}
  539. <div class="content">
  540. <p>
  541. The <code>navbar-brand</code> is the left side of the navbar. It can contain:
  542. </p>
  543. <ul>
  544. <li>
  545. a number of <code>navbar-item</code>
  546. </li>
  547. <li>
  548. the <code>navbar-burger</code> as last child
  549. </li>
  550. </ul>
  551. </div>
  552. {% highlight html %}{{navbar_brand_example}}{% endhighlight %}
  553. <div class="content">
  554. <p>
  555. 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.
  556. </p>
  557. </div>
  558. <div class="bd-example is-paddingless">
  559. {{navbar_brand_items_example}}
  560. </div>
  561. {% highlight html %}{{navbar_brand_items_example}}{% endhighlight %}
  562. <div class="content">
  563. <p>
  564. On desktop {% include bp/desktop.html %}, the navbar brand will only take up the space it needs.
  565. </p>
  566. </div>
  567. {% include anchor.html name="Navbar burger" %}
  568. <div class="content">
  569. <p>
  570. 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>.
  571. </p>
  572. </div>
  573. <div class="bd-example is-paddingless">
  574. <div class="navbar-burger" style="display: flex;">
  575. <span></span>
  576. <span></span>
  577. <span></span>
  578. </div>
  579. </div>
  580. {% highlight html %}{{ navbar_burger_example }}{% endhighlight %}
  581. <div class="content">
  582. <p>
  583. You can add the modifier class <code>is-active</code> to turn it into a cross.
  584. </p>
  585. </div>
  586. <div class="bd-example is-paddingless">
  587. <div class="navbar-burger is-active" style="display: flex;">
  588. <span></span>
  589. <span></span>
  590. <span></span>
  591. </div>
  592. </div>
  593. {% include anchor.html name="Navbar menu" %}
  594. <div class="content">
  595. <p>
  596. 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>.
  597. </p>
  598. </div>
  599. {% highlight html %}{{navbar_menu_example}}{% endhighlight %}
  600. <div class="content">
  601. <p>
  602. 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.
  603. </p>
  604. </div>
  605. {% highlight html %}{{navbar_menu_active_example}}{% endhighlight %}
  606. <div class="content">
  607. <p>
  608. 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:
  609. </p>
  610. <ul>
  611. <li>
  612. <code>navbar-start</code>
  613. </li>
  614. <li>
  615. <code>navbar-end</code>
  616. </li>
  617. </ul>
  618. </div>
  619. <hr>
  620. <div id="navbarJsExample" class="message is-info">
  621. <h4 class="message-header">Javascript toggle</h4>
  622. <div class="message-body">
  623. <div class="content">
  624. <p>
  625. The Bulma package <strong>does not come with any JavaScript</strong>.
  626. <br>
  627. 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>.
  628. </p>
  629. {% highlight html %}{{ navbar_js_html }}{% endhighlight %}
  630. {% highlight javascript %}{{ navbar_js_code }}{% endhighlight %}
  631. </div>
  632. </div>
  633. </div>
  634. {% include anchor.html name="Navbar start and navbar end" %}
  635. <div class="content">
  636. <p>
  637. The <code>navbar-start</code> and <code>navbar-end</code> are the two direct and only children of the <code>navbar-menu</code>.
  638. </p>
  639. <p>
  640. On desktop {% include bp/desktop.html %}:
  641. </p>
  642. <ul>
  643. <li>
  644. <code>navbar-start</code> will appear on the <strong>left</strong>
  645. </li>
  646. <li>
  647. <code>navbar-end</code> will appear on the <strong>right</strong>
  648. </li>
  649. </ul>
  650. <p>
  651. Each of them can contain any number of <code>navbar-item</code>.
  652. </p>
  653. </div>
  654. {% highlight html %}{{navbar_start_end_example}}{% endhighlight %}
  655. {% include anchor.html name="Navbar item" %}
  656. <div class="content">
  657. <p>
  658. A <code>navbar-item</code> is a repeatable element that can be:
  659. </p>
  660. <ul>
  661. <li>
  662. a navigation <strong>link</strong>
  663. {% highlight html %}{{ navbar_item_link_example }}{% endhighlight %}
  664. </li>
  665. <li>
  666. a container for the <strong>brand logo</strong>
  667. {% highlight html %}{{ navbar_item_brand_example }}{% endhighlight %}
  668. </li>
  669. <li>
  670. the <strong>parent</strong> of a dropdown menu
  671. {% highlight html %}{{ navbar_item_dropdown_example }}{% endhighlight %}
  672. </li>
  673. <li>
  674. a child of a <strong>navbar dropdown</strong>
  675. {% highlight html %}{{ navbar_item_dropdown_bis_example }}{% endhighlight %}
  676. </li>
  677. <li>
  678. a container for almost <strong>anything</strong> you want, like a <code>field</code>
  679. {% highlight html %}{{ navbar_item_other_example }}{% endhighlight %}
  680. </li>
  681. </ul>
  682. <p>
  683. 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:
  684. </p>
  685. <ul>
  686. <li>
  687. <code>navbar</code>
  688. </li>
  689. <li>
  690. <code>navbar-brand</code>
  691. </li>
  692. <li>
  693. <code>navbar-start</code>
  694. </li>
  695. <li>
  696. <code>navbar-end</code>
  697. </li>
  698. <li>
  699. <code>navbar-dropdown</code>
  700. </li>
  701. </ul>
  702. </div>
  703. {% include anchor.html name="Transparent navbar" %}
  704. <div class="content">
  705. <p>
  706. 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.
  707. </p>
  708. </div>
  709. <div class="bd-example is-paddingless">
  710. {{navbar_transparent_example}}
  711. </div>
  712. {% highlight html %}{{navbar_transparent_example}}{% endhighlight %}
  713. {% include anchor.html name="Dropdown menu" %}
  714. <div class="content">
  715. <p>
  716. To create a <strong>dropdown menu</strong>, you will need <strong>4</strong> elements:
  717. </p>
  718. <ul>
  719. <li>
  720. <code>navbar-item</code> with the <code>has-dropdown</code> modifier
  721. </li>
  722. <li>
  723. <code>navbar-link</code> which contains the dropdown arrow
  724. </li>
  725. <li>
  726. <code>navbar-dropdown</code> which can contain instances of <code>navbar-item</code> and <code>navbar-divider</code>
  727. </li>
  728. </ul>
  729. </div>
  730. <div class="columns">
  731. <div class="column">
  732. <div class="bd-example is-paddingless">
  733. {{ navbar_dropdown_example }}
  734. </div>
  735. </div>
  736. <div class="column">
  737. {% highlight html %}{{ navbar_dropdown_example }}{% endhighlight %}
  738. </div>
  739. </div>
  740. <h4 class="title is-4">
  741. Show/hide the dropdown with either <strong>CSS</strong> or <strong>JavaScript</strong>
  742. </h4>
  743. <div class="content">
  744. <p>
  745. 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.
  746. </p>
  747. <p>
  748. The <code>navbar-item</code> with the <code>has-dropdown</code> modifier, has <strong>2 additional modifiers</strong>
  749. </p>
  750. <ul>
  751. <li>
  752. <code>is-hoverable</code>: the dropdown will show up when <strong>hovering</strong> the parent <code>navbar-item</code>
  753. </li>
  754. <li>
  755. <code>is-active</code>: the dropdown will show up <strong>all the time</strong>
  756. </li>
  757. </ul>
  758. </div>
  759. <div class="message is-success">
  760. <p class="message-body">
  761. 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>.
  762. </p>
  763. </div>
  764. {% highlight html %}{{ navbar_dropdown_hover_snippet }}{% endhighlight %}
  765. <div class="columns">
  766. <div class="column">
  767. <div class="bd-example is-paddingless">
  768. {{ navbar_dropdown_hover_example }}
  769. </div>
  770. </div>
  771. <div class="column">
  772. {% highlight html %}{{ navbar_dropdown_hover_example }}{% endhighlight %}
  773. </div>
  774. </div>
  775. {% highlight html %}{{ navbar_dropdown_active_snippet }}{% endhighlight %}
  776. <div class="columns">
  777. <div class="column">
  778. <div class="bd-example is-paddingless">
  779. {{ navbar_dropdown_active_example }}
  780. </div>
  781. </div>
  782. <div class="column">
  783. {% highlight html %}{{ navbar_dropdown_active_example }}{% endhighlight %}
  784. </div>
  785. </div>
  786. <h4 class="title is-4">
  787. Right dropdown
  788. <span class="tag is-info">0.5.1</span>
  789. </h4>
  790. <div class="content">
  791. <p>
  792. 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.
  793. </p>
  794. </div>
  795. {% highlight html %}{{ navbar_dropdown_right_snippet }}{% endhighlight %}
  796. <div class="columns">
  797. <div class="column">
  798. <div class="bd-example is-paddingless">
  799. {{ navbar_dropdown_right_example }}
  800. </div>
  801. </div>
  802. <div class="column">
  803. {% highlight html %}{{ navbar_dropdown_right_example }}{% endhighlight %}
  804. </div>
  805. </div>
  806. <h4 class="title is-4">
  807. Styles for the dropdown menu
  808. </h4>
  809. <div class="content">
  810. <p>
  811. By default, the <code>navbar-dropdown</code> has:
  812. </p>
  813. <ul>
  814. <li>
  815. a grey <code>border-top</code>
  816. </li>
  817. <li>
  818. a <code>border-radius</code> at both bottom corners
  819. </li>
  820. </ul>
  821. </div>
  822. <div class="columns">
  823. <div class="column">
  824. <div class="bd-example is-paddingless">
  825. {{ navbar_dropdown_default_example }}
  826. </div>
  827. </div>
  828. <div class="column">
  829. {% highlight html %}{{ navbar_dropdown_default_example }}{% endhighlight %}
  830. </div>
  831. </div>
  832. <div class="content">
  833. <p>
  834. 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.
  835. </p>
  836. <ul>
  837. <li>
  838. the grey border is <strong>removed</strong>
  839. </li>
  840. <li>
  841. a slight <strong>inner shadow</strong> is added
  842. </li>
  843. <li>
  844. all corners are <strong>rounded</strong>
  845. </li>
  846. <li>
  847. the hover/active state is <strong>animated</strong>
  848. </li>
  849. </ul>
  850. </div>
  851. <div class="columns">
  852. <div class="column">
  853. <div class="bd-example is-paddingless">
  854. {{ navbar_dropdown_boxed_example }}
  855. </div>
  856. </div>
  857. <div class="column">
  858. {% highlight html %}{{ navbar_dropdown_boxed_example }}{% endhighlight %}
  859. </div>
  860. </div>
  861. <h4 class="title is-4">
  862. Active dropdown navbar item
  863. </h4>
  864. <div class="columns">
  865. <div class="column">
  866. <div class="bd-example is-paddingless">
  867. {{ navbar_dropdown_item_active_example }}
  868. </div>
  869. </div>
  870. <div class="column">
  871. {% highlight html %}{{ navbar_dropdown_item_active_example }}{% endhighlight %}
  872. </div>
  873. </div>
  874. <h4 class="title is-4">
  875. Dropdown divider
  876. </h4>
  877. <div class="content">
  878. <p>
  879. You can add a <code>navbar-divider</code> to display a <strong>horizontal rule</strong> in a <code>navbar-dropdown</code>.
  880. </p>
  881. </div>
  882. {% highlight html %}{{ navbar_divider_example }}{% endhighlight %}
  883. {% include anchor.html name="Colors" %}
  884. <div class="tags has-addons">
  885. <span class="tag">New!</span>
  886. <span class="tag is-info">0.5.2</span>
  887. </div>
  888. <div class="content">
  889. <p>
  890. You can change the background color of the <code>navbar</code> by using one of the <strong>9 color modifiers:</strong>
  891. </p>
  892. <ul>
  893. <li><code>is-primary</code></li>
  894. <li><code>is-info</code></li>
  895. <li><code>is-success</code></li>
  896. <li><code>is-warning</code></li>
  897. <li><code>is-danger</code></li>
  898. <li><code>is-black</code></li>
  899. <li><code>is-dark</code></li>
  900. <li><code>is-light</code></li>
  901. <li><code>is-white</code></li>
  902. </ul>
  903. </div>
  904. {% highlight html %}{{ navbar_color_markup }}{% endhighlight %}
  905. <div class="bd-example is-paddingless">
  906. {% include examples/navbar-color.html color="primary" %}
  907. </div>
  908. <div class="bd-example is-paddingless">
  909. {% include examples/navbar-color.html color="info" %}
  910. </div>
  911. <div class="bd-example is-paddingless">
  912. {% include examples/navbar-color.html color="success" %}
  913. </div>
  914. <div class="bd-example is-paddingless">
  915. {% include examples/navbar-color.html color="warning" light=true %}
  916. </div>
  917. <div class="bd-example is-paddingless">
  918. {% include examples/navbar-color.html color="danger" %}
  919. </div>
  920. <div class="bd-example is-paddingless">
  921. {% include examples/navbar-color.html color="black" %}
  922. </div>
  923. <div class="bd-example is-paddingless">
  924. {% include examples/navbar-color.html color="dark" %}
  925. </div>
  926. <div class="bd-example is-paddingless">
  927. {% include examples/navbar-color.html color="light" light=true %}
  928. </div>
  929. <div class="bd-example is-paddingless">
  930. {% include examples/navbar-color.html color="white" light=true %}
  931. </div>
  932. {% include variables.html %}
  933. </div>
  934. </section>