navbar.html 34 KB

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