© Aravind Shenoy 2020
A. ShenoyLearning Bulmahttps://doi.org/10.1007/978-1-4842-5482-0_4

4. Navigation and Media Components

Aravind Shenoy1 
(1)
Mumbai, Maharashtra, India
 

This chapter examines Bulma’s navigation and media components. Bulma’s intuitive and easy-to-use navigation components enable access to content and commercial functionalities such as checkout areas, while the media attributes enable sophisticated web design. Bulma’s navigation components enable users to find content quickly and easily. They also help organize content in a streamlined manner, kind of a hallmark for efficient web design. Let’s take a look at the various navigation and media elements.

Navigation Components

Navigation elements are an imperative aspect in designing modern layouts. They are used as a roadmap for the content on your site interface. Aesthetics account for nothing if your users cannot interact with your site easily. Therefore, navigation elements help visitors access that information quickly, eliminating the guesswork of finding the solution/content, which encouraged them to explore your web site in the first place. On a pan-optic level, navigation elements increase the user–site engagement and conversion rate while reducing the bounce rate significantly.

Bulma has several navigation components that streamline the usability factor significantly in a minimalistic way, without the bulk or clutter.

Bulma’s navigation elements comprise breadcrumbs, drop-down menus, navbar (think navigation bar), and tabs that enable rapid user accessibility in a “no-frills” way.

Breadcrumbs

Breadcrumbs are a type of navigation system, which pinpoint the user location on the web app or web site. Breadcrumbs also improve site accessibility and exploration immensely, since they show the user location. The user can understand the hierarchy, and thus this navigation element is quite handy when there is massive content in the site.

Breadcrumbs are a common feature in web apps or sites that have several categories of displayed products/goods—this makes it easier to navigate to a particular category in case you want to check out the different products of similar make/genre. With an ultimate focus on site hierarchy, it enhances the way in which users are aware of the web page or any specific content location, paving the way for an excellent user experience.

Listing 4-1 explains the basic code for breadcrumbs.
<div class="box">
 <nav class="breadcrumb" aria-label="breadcrumbs">
  <ul>
     <li class="is-active"><a href="#">Home</a></li>
     <li><a href="#">Documentation</a></li>
     <li><a href="#">Downloads</a></li>
     <li><a href="#">Support</a></li>
     <li><a href="#">Blogs</a></li>
     <li><a href="#" aria-current="page">Gallery</a></li>
     <li><a href="#">Contact</a></li>
  </ul>
 </nav>
</div>
Listing 4-1

Basic Breadcrumb Code

In Listing 4-1, we create a box container by using the box class with a <div> element. Then we add a navigation element with the <nav> tag. We go on to assign the breadcrumb class to the <nav> tag. We create an unordered list using the parent <ul> and its child <li> tags.

To the first <li> tag, we assign the is-active class and name it Home. The is-active class will indicate the first <li> tag as the current active item. We then create six more <li> tags and name them accordingly, as seen in Listing 4-1.

The output of the code is shown in Figure 4-1.
../images/485437_1_En_4_Chapter/485437_1_En_4_Fig1_HTML.jpg
Figure 4-1

Basic breadcrumb

In the Bulma breadcrumb component, you can align the breadcrumb to the right or center. Bulma supports different separators like bullet separator, has-succeeds separator, and the arrow separator.

In Listing 4-2, we align the breadcrumb to the right and change the separator to an arrow separator.
<div class="container">
 <nav class="breadcrumb has-arrow-separator is-right" aria-label="breadcrumbs">
  <ul>
     <li class="is-active"><a href="#">Home</a></li>
     <li><a href="#">Documentation</a></li>
     <li><a href="#">Downloads</a></li>
     <li><a href="#">Support</a></li>
     <li><a href="#">Blogs</a></li>
     <li><a href="#" aria-current="page">Gallery</a></li>
     <li><a href="#">Contact</a></li>
  </ul>
</nav>
Listing 4-2

Right-Align Breadcrumb with Arrow Separator

As you see, most of the code is the same as in Listing 4-1. Instead of the box layout, we use the container class as the main <div> element instead of a box layout.

Coming back to the relevant stuff, we add the classes has-arrow-separator and is-right alongside the default breadcrumb class in the <nag> tag. The rest of the code is the same, where we create an unordered list and define the name for each list item.

The output of the code is shown in Figure 4-2.
../images/485437_1_En_4_Chapter/485437_1_En_4_Fig2_HTML.jpg
Figure 4-2

Right-aligned breadcrumb with an arrow separator

Moving forward, in Listing 4-3 we have an example of breadcrumbs aligned to the center of the layout. Breadcrumbs in Bulma have small, medium, and large classes apart from the default normal class, using which you can change the size of the breadcrumb as in Listing 4-3.
<div class="container">
 <nav class="breadcrumb is-small is-centered has-bullet-separator" aria-label="breadcrumbs">
  <ul>
     <li class="is-active"><a href="#">Home</a></li>
     <li><a href="#">Documentation</a></li>
     <li><a href="#">Downloads</a></li>
     <li><a href="#">Support</a></li>
     <li><a href="#">Blogs</a></li>
     <li><a href="#" aria-current="page">Gallery</a></li>
     <li><a href="#">Contact</a></li>
  </ul>
</nav>
</div>
<br><br><br>
<div class="container">
<nav class="breadcrumb is-large is-centered has-succeeds-separator" aria-label="breadcrumbs">
  <ul>
     <li class="is-active"><a href="#">Home</a></li>
     <li><a href="#">Documentation</a></li>
     <li><a href="#">Downloads</a></li>
     <li><a href="#">Support</a></li>
     <li><a href="#">Blogs</a></li>
     <li><a href="#" aria-current="page">Gallery</a></li>
     <li><a href="#">Contact</a></li>
  </ul>
 </nav>
</div>
Listing 4-3

Centered Breadcrumb with Different Sizes and Separators

In Listing 4-3, we create a container for the first breadcrumb. We use the is-small class, is-centered, and has-bullet-separator in conjunction with the breadcrumb class for the first breadcrumb. The rest of the code for the first breadcrumb is similar to the earlier code listings, where we create an unordered list to define names for the breadcrumbs.

Then we create the second breadcrumb inside another container where we add the is-large class, is-centered, and has-succeeds-separator classes in conjunction with the breadcrumb class. The rest of the code is the same as earlier examples, where we create an unordered list and define the names of the breadcrumb items.

The output of the code is shown in Figure 4-3.
../images/485437_1_En_4_Chapter/485437_1_En_4_Fig3_HTML.jpg
Figure 4-3

Centered breadcrumbs in small and large sizes

As you can see in Figure 4-3, both the breadcrumbs are aligned to the center. While the first breadcrumb is small in size, the breadcrumb below is large in size. Observe the bullet separator and has-succeeds separators for the first and last breadcrumbs, respectively.

You can also use icons in conjunction with the breadcrumb items. Listing 4-4 shows an example of merging icons with the breadcrumbs in Bulma.
<div class="container">
 <nav class="breadcrumb is-centered" aria-label="breadcrumbs">
  <ul>
    <li>
      <a>
        <span class="icon is-small"><i class="fas fa-home"></i>&nbsp;</span>
         <span>Home</span>
      </a>
    </li>
    <li>
     <a>
         <span class="icon is-small"><i class="fas fa-download"></i>&nbsp;</span>
         <span>Downloads</span>
      </a>
    </li>
    <li>
     <a>
         <span class="icon is-small"><i class="fas fa-file-contract"></i>&nbsp;</span>
         <span>Products</span>
      </a>
    </li>
    <li class="is-active">
     <a>
         <span class="icon is-small"><i class="fas fa-users-cog"></i>&nbsp;</span>
         <span>Support</span>
      </a>
    </li>
    <li>
      <a>
         <span class="icon is-small"><i class="fab fa-dochub"></i>&nbsp;</span>
         <span>Docs</span>
      </a>
    </li>
    <li>
      <a>
         <span class="icon is-small"><i class="fab fa-blogger-b"></i>&nbsp;</span>
         <span>Blogs</span>
      </a>
    </li>
    <li>
      <a>
          <span class="icon is-small"><i class="fas fa-phone-alt"></i>&nbsp;</span>
         <span>Contact</span>
      </a>
    </li>
  </ul>
 </nav>
</div>
Listing 4-4

Merging Icons with Breadcrumbs

In Listing 4-4, we define a main <div> with the container class. Inside we create another <div> element and assign the breadcrumb class in conjunction with the is-centered class to position the breadcrumb at the center of the row.

Then we create the breadcrumb using the unordered lists with the <ul> and <li> tags. The only difference is that we use the <span> element within each <li> class and define an icon next to the breadcrumb item name. For example, within the <a> tags within the first <li> tag, we define a Home icon within the span tags using the following line of code.
<span class="icon is-small"><i class="fas fa-home"></i>&nbsp;</span>

&nbsp; creates an empty space after the icon. We have also used the is-small class in the span tag and the home icon within the <i> tags, which are within the <span> tags.

We have used the latest Font Awesome 5.x icons. For that, we have used the following link in the <head> section before the <body> section of the code:
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.10.2/css/all.min.css" integrity="sha256-zmfNZmXoNWBMemUOo1XUGFfc0ihGGLYdgtJS3KCr/l0=" crossorigin="anonymous" />

Then, we define different icons within each <li> tag for each breadcrumb item based on the relevant names. Also, we have kept the Support breadcrumb item as the current item using the is-active class.

The output of the code is shown in Figure 4-4.
../images/485437_1_En_4_Chapter/485437_1_En_4_Fig4_HTML.jpg
Figure 4-4

Breadcrumb with icons

Drop-Downs

Drop-downs are usually created to show the different items/content in a compact way—for example, the distinct categories commonly seen on e-commerce web sites are designed in a panel-like drop-down. You can design an apt site structure and include diverse menu items in a drop-down, eliminating too many links or congestion on the web page. Apart from a clean layout, it also eliminates the need to scroll repeatedly, as the user can access specific information from the links in the drop-down list.

From a UX/UI perspective, you have to consider the mobile platform, where it becomes a different ballgame altogether due to the touch feature and highly compact screens. Also, the links, data, or information in a drop-down should be well organized in line with the user needs. Bulma’s drop-down feature is tailored for all platforms, and is especially compatible with the mobile screen interface owing to its mobile-first paradigm.

Let’s see the process of creating drop-down menus in Bulma (Listing 4-5).
<div class="dropdown is-active">
  <div class="dropdown-trigger">
    <button class="button has-background-white-bis">
      <span>Services</span>
      <span class="icon is-small">
        <i class="fas fa-angle-down" aria-hidden="true"></i>
      </span>
    </button>
  </div>
  <div class="dropdown-menu" id="dropdown-menu" role="menu">
    <div class="dropdown-content">
      <a href="#" class="dropdown-item item is-active">
        Web Design
      </a>
      <a class="dropdown-item">
        Mobile app Development
      </a>
      <a href="#" class="dropdown-item">
        SEO
      </a>
      <a href="#" class="dropdown-item">
      </a>
      <a href="#" class="dropdown-item">
        PPC
      </a>
      <hr class="dropdown-divider">
      <a href="#" class="dropdown-item">
        UX/UI design
      </a>
      <a href="#" class="dropdown-item">
        Email Marketing Creative Design
      </a>
      <a href="#" class="dropdown-item">
         Logo & Brand Identity Design
      </a>
    </div>
  </div>
</div>
Listing 4-5

Creating a Drop-Down Menu

In Listing 4-5, we create a <div> element with the dropdown class to make it a main container. For the drop-down button, we create another <div> element and assign the dropdown-trigger class to it. Within this <div>, we define the drop-down button with a white background and, using the icon in conjunction with the button element, we create a small drop-down arrow.

Once we are done with the drop-down button, we create a separate drop-down menu where we will define the drop-down content. We create a <div> and assign the dropdown-menu class to it. Within that <div>, we create a child <div> and assign the dropdown-content to it. Next, we create several links using the anchor <a> link tags with the dropdown-item classes.

After we define four links, we create a drop-down divider using the <hr> tags with the dropdown-divider class. Thereon, we create three more links using the <a> tags with the dropdown-item class for each link.

The output of the code is shown in Figure 4-5.
../images/485437_1_En_4_Chapter/485437_1_En_4_Fig5_HTML.jpg
Figure 4-5

Drop-down menu

You can also use prose content instead of links in the drop-down content. For that, use <div> for each drop-down item instead of the <a> link tags. You can also use a hover effect, which will display the drop-down menu items on hover.
<div class="dropdown is-hoverable">
  <div class="dropdown-trigger">
    <button class="button has-background-white-ter">
      <span>Services</span>
      <span class="icon is-small">
        <i class="fas fa-angle-down" aria-hidden="true"></i>
      </span>
    </button>
  </div>
  <div class="dropdown-menu" id="dropdown-menu" role="menu">
    <div class="dropdown-content">
      <div href="#" class="dropdown-item">
       Cat ipsum dolor sit amet, molestiae deserunt. Quam lorem aut. Ipsa magnam yet quo
      </div>
      <hr class="dropdown-divider">
      <div href="#" class="dropdown-item">
       Adipisci sit but omnis quae. Aute eius for exercitationem occaecat commodi so abb
      </div>
        <hr class="dropdown-divider">
         <div href="#" class="dropdown-item">
       sit amet, molestiae deserunt. Quam lorem aut. Ipsa magnam yet quo aut. Ipsa magnam
      </div>
    </div>
  </div>
</div>
</div>
Listing 4-6

Using Content for Drop-Downs with Hover Facility

In Listing 4-6, we create similar drop-down functionality but we add the is-hoverable class in conjunction with the dropdown class for the main <div> element. Then, we create the drop-down button as in the earlier example.

The difference is when we create the drop-down menu. Within the <div> with the dropdown-content class, we create <div> elements and assign the dropdown-item class to each of the menu items as shown in Listing 4-6.

The output of the code will display a drop-down button called Services and, on hovering over it, you can see the drop-down menu items as shown in Figure 4-6.
../images/485437_1_En_4_Chapter/485437_1_En_4_Fig6_HTML.jpg
Figure 4-6

Drop-down menu with prose content on hover action

Tabs

Tabs are an excellent navigation system due to the linear representation of the site structure. Tabs not only help you divide the content into separate sections but also provide a way to access that content. Their intuitive architecture makes users aware of their location on the site quickly.

However, the usability factor of the navigation tabs element depends on how you organize and use their functionality—for example, the heading for each tab should have minimal characters or shorter lengths. Tabs are quite effective when you want to show a string of similar categories/similar genres.

Bulma’s tabs component is quite easy to design and helps site/app’s visitors to access chunks of data in a simple way. However, web designers/developers should take into account the specific user needs, amount of data, and how rapidly users can access that content.

Let’s look at the procedure to create tabs in Bulma, as seen in Listing 4-7.
<div class="tabs">
  <ul>
    <li class="is-active"><a>Home</a></li>
    <li><a>About</a></li>
    <li><a>Downloads</a></li>
    <li><a>Support</a></li>
    <li><a>Gallery</a></li>
    <li><a>Tutorials</a></li>
    <li><a>Documentation</a></li>
    <li><a>Contact</a></li>
   </ul>
</div>
Listing 4-7

Creating Basic Tabs

In Listing 4-7, we create a main <div> element and assign the tabs class to it. Then we create an unordered list within that <div> using the <ul> and <li> tags. We assign the is-active class to the first <li> tag to make it the current item.

The output of the code is shown in Figure 4-7.
../images/485437_1_En_4_Chapter/485437_1_En_4_Fig7_HTML.jpg
Figure 4-7

Tabs navigation system

As you can see, we have a simple navigation system.

You can also align the tabs at the center or right and change the size to small, large, or medium using the respective classes. You can use icons for each tab in tandem with the name. Apart from that, you can create a classic tabs look using the boxed functionality, as shown in Listing 4-8.
<div class="tabs is-centered is-large is-boxed">
  <ul>
    <li class="is-active">
      <a>
        <span class="icon is-small"><i class="fas fa-home"></i>&nbsp;</span>
         <span>Home</span>
      </a>
    </li>
    <li>
      <a>
         <span class="icon is-small"><i class="fas fa-download"></i>&nbsp;</span>
         <span>Downloads</span>
      </a>
    </li>
    <li>
      <a>
         <span class="icon is-small"><i class="fas fa-file-contract"></i>&nbsp;</span>
         <span>Products</span>
      </a>
    </li>
    <li>
      <a>
         <span class="icon is-small"><i class="fas fa-users-cog"></i>&nbsp;</span>
         <span>Support</span>
      </a>
    </li>
    <li>
      <a>
         <span class="icon is-small"><i class="fab fa-dochub"></i>&nbsp;</span>
         <span>Docs</span>
      </a>
    </li>
    <li>
      <a>
         <span class="icon is-small"><i class="fab fa-blogger-b"></i>&nbsp;</span>
         <span>Blogs</span>
      </a>
    </li>
      <a>
          <span class="icon is-small"><i class="fas fa-phone-alt"></i>&nbsp;</span>
         <span>Contact</span>
      </a>
    </li>
  </ul>
</div>
Listing 4-8

Defining Classic-Style Tabs with Boxed Attribute

In Listing 4-8, we create the parent <div> and assign the tabs class to it as seen in the earlier example. In conjunction with the tabs class, we also use the following classes:
  • is-centered class for aligning tabs to the center

  • is-large class for creating large-sized tabs

  • is-boxed class for the classic tabs look

Within the parent <div>, we create an unordered list using the <ul> and <li> tags. We use the <span> tags within link <a> tags for each <li> tags as shown in the following line of code:
<span class="icon is-small"><i class="fas fa-home"></i>&nbsp;</span> <span>Home</span>

Similarly, we create several tabs items.

The output of the code is shown in Figure 4-8.
../images/485437_1_En_4_Chapter/485437_1_En_4_Fig8_HTML.jpg
Figure 4-8

Boxed tabs with icons at the center

As you can see from the output, the tabs are positioned at the center of the row and have the relevant items next to the tab names. Moreover, you can also see the classic boxed look for the Home tab, which is the default current tab as defined in the code.

You can also define an exclusive look to each tab, where each tab will have a border. This is done with the toggle class. You can also use rounded borders for the first and last tabs, as shown in Listing 4-9.
 <div class="tabs is-boxed is-toggle is-toggle-rounded">
  <ul>
    <li class="is-active">
      <a>
        <span class="icon is-small"><i class="fas fa-home"></i>&nbsp;</span>
         <span>Home</span>
      </a>
    </li>
    <li>
      <a>
         <span class="icon is-small"><i class="fas fa-download"></i>&nbsp;</span>
         <span>Downloads</span>
      </a>
    </li>
    <li>
      <a>
         <span class="icon is-small"><i class="fas fa-file-contract"></i>&nbsp;</span>
         <span>Products</span>
      </a>
    </li>
    <li>
      <a>
         <span class="icon is-small"><i class="fas fa-users-cog"></i>&nbsp;</span>
         <span>Support</span>
      </a>
    </li>
<li>
      <a>
         <span class="icon is-small"><i class="fab fa-dochub"></i>&nbsp;</span>
         <span>Docs</span>
      </a>
    </li>
    <li>
      <a>
         <span class="icon is-small"><i class="fab fa-blogger-b"></i>&nbsp;</span>
         <span>Blogs</span>
      </a>
    </li>
    <li>
      <a>
         <span class="icon is-small"><i class="fas fa-images"></i>&nbsp;</span>
         <span>Gallery</span>
      </a>
    </li>
    <li>
      <a>
          <span class="icon is-small"><i class="fas fa-phone-alt"></i>&nbsp;</span>
         <span>Contact</span>
      </a>
    </li>
 </ul>
</div>
Listing 4-9

Rounded Shape Tabs with Exclusive Borders

In Listing 4-9, we use the is-boxed and is-toggle classes together in conjunction with the tabs class to allocate a boxed border for each tab. We also use another class, is-toggle-rounded, in conjunction with those classes to give a rounded border for the first and last tabs.

The rest of the code is similar to the earlier example, where we have created tabs with icons using an unordered list.

The output of the code is shown in Figure 4-9.
../images/485437_1_En_4_Chapter/485437_1_En_4_Fig9_HTML.jpg
Figure 4-9

Boxed border for all tabs with rounded borders at each end

Navbar

Bulma’s navbar element helps design a horizontal list of links enabling site visitors to access any section in the site. However, from a UI/UX perspective, it has to be minimalistic and simple. The headings should be short in length and the number of headings should be not more than 5 or 6, as it may create unnecessary clutter. You should never design a navbar first and then fit in the content. In fact, it should be the other way around—the navbar should be designed keeping content at the crux of your site structure, to ensure high-degree of readability and rapid access.

Let’s examine the navbar design in Bulma, as shown in Listing 4-10.
<nav class="navbar has-background-grey">
<div class="navbar-brand">
    <a class="navbar-item" href="https://pixabay.com/photos/oracle-girl-photomontage-witch-2133976/">
       <img src="Images/Oracle.png" alt="Oracle">
    </a>
      <a class="navbar-burger burger" data-target="navMenu">
        <span></span>
        <span></span>
        <span></span>
      </a>
</div>
<div id="navMenu" class="navbar-menu">
<div class="navbar-start">
        <a href="#" class="navbar-item has-text-white is-active"><b>Horoscope</b></a>
        <a href="#" class="navbar-item has-text-white"><b>Astrology</b></a>
        <a href="#" class="navbar-item has-text-white"><b>Psychics Experts</b></a>
        <a href="#" class="navbar-item has-text-white"><b>Predictions</b></a>
        <a href="#" class="navbar-item has-text-white"><b>Occult</b></a>
  </strong>
      </div>
<div class="navbar-end">
      <div class="navbar-item">
        <div class="buttons">
          <a class="button is-outlined">
            <strong>Login</strong>
          </a>
        </div>
      </div>
    </div>
  </div>
</nav>
Listing 4-10

Creating a Simple Navbar

In Listing 4-10, we define a navigation element <nav> and assign the navbar class to it. The navbar class results in a navigation bar container. Within the <nav> tags, we create a main < div> tag and assign the navbar-brand class to it. This navbar-brand element is the left side of the navbar, which is always visible and usually contains logo and links. Thereon, we create an anchor tag and assign the navbar-item class to it. The navbar-item class usually is used for various items on the navbar, but here we use it for the anchor link, pointing toward a site. Then we define the logo using the <img> tag.

Next, we create the hamburger icon, which is called the navbar-burger in Bulma. For this, we create another anchor tag and assign the navbar-burger class to it. We use a burger class in conjunction with the navbar-burger class to facilitate action using JavaScript. We set a data-target attribute and assign the value Navicon to it. We create three <span> elements without any label or name for creating three lines of the hamburger icon functionality.

Once we are done with the navburger, we create a separate <div> and assign the navbar-menu class to it. We also assign an id, whose value is the Navicon, which incidentally is also the value of the data-target attribute mentioned earlier.

Then we create another <div> tag within the preceding <div> and define the navbar-start class to it, which will align the navbar menu to the left of the logo. We move on to create five anchor links and assign the navbar-item class to each of them, and define the menu items on the navbar at the left of the logo.

Next, we create another <div> and assign the navbar-end class to it. This will align the menu-items defined here to the right of the navbar. We define a <div> element within it and assign the navbar-item class to it. We create a Login button and assign the is-outlined class to it.

The output of the code is shown in Figure 4-10.
../images/485437_1_En_4_Chapter/485437_1_En_4_Fig10_HTML.jpg
Figure 4-10

Navbar with logo and menu items

Media Components

Media components help display media in different ways, depending on their use cases or functionality. In this section, we will look at progress bars, notifications, images, tags, and pagination components in Bulma.

Progress Bars

A progress bar is an excellent way of showing the progress of any action. It is usually an indicator of the downloading process and enables the user to visualize the progression of the download operation.

Bulma’s progress bar is explained in Listing 4-11.
<div class="box">
<progress class="progress is-primary" value="15" max="100">15%</progress>
<progress class="progress is-warning" value="35" max="100">35%</progress>
</div>
Listing 4-11

Creating Progress Bars with Contextual Colors

In Listing 4-11, we create a box container and define two progress bars. We use the <progress> element and assign a progress class to it, and also assign a contextual primary color to it using the is-primary class. We set the bar value as 15, with 100 being the maximum value. For this, we use the value attribute and the max attribute.

Next, we similarly define the second progress bar with 35 as the value and a maximum value of 100. We assign the contextual warning color to it.

The output of the code is shown in Figure 4-11.
../images/485437_1_En_4_Chapter/485437_1_En_4_Fig11_HTML.jpg
Figure 4-11

Normal progress bars with different values and contextual colors

In Bulma, you can assign different sizes to the progress bars. In Listing 4-12, we use the is-medium class for the progress bars with different contextual colors.
<div class="box">
<progress class="progress is-info is-medium" value="50" max="100">50%</progress>
<progress class="progress is-success is-medium" value="65" max="100">65%</progress>
</div>
Listing 4-12

Creating Progress Bars with Medium Size

In Listing 4-12, we create two progress bars and assign the values 50 and 65 in conjunction with the progress class. We use the is-medium size class for both progress bars. We also define the contextual colors by assigning the is-info and is-success classes to them, respectively.

The output of the code is shown in Figure 4-12.
../images/485437_1_En_4_Chapter/485437_1_En_4_Fig12_HTML.jpg
Figure 4-12

Progress bars with medium-size and contextual colors

Next, we see the effect of the large class, which results in large-sized progress bars, in Listing 4-13.
<div class="box">
<progress class="progress is-link is-large" value="77" max="100">77%</progress>
<progress class="progress is-danger is-large" value="90" max="100">90%</progress>
</div>
Listing 4-13

Creating Large-Sized Progress Bars

In Listing 4-13, we create two progress bars and assign the is-large class in conjunction with the progress class to each of them. We define the link and danger contextual colors to the two progress bars, and also define 77 and 90 as the values for the two progress bars.

The output of the code is shown in Figure 4-13.
../images/485437_1_En_4_Chapter/485437_1_En_4_Fig13_HTML.jpg
Figure 4-13

Large-sized progress bars with contextual colors

If we do not assign any value to the progress bar, it will result in an intermediate buffering state for the progress bar, as shown in Listing 4-14.
<div class="box">
<progress class="progress is-primary" max="100">15%</progress>
<progress class="progress is-warning" max="100">35%</progress>
</div>
Listing 4-14

Creating Intermediate Buffering State Progress Bars

In Listing 4-14, we have created 2 progress bars with different contextual colors but we have not used a value attribute though we have retained the max attribute.

The output of the code is shown in Figure 4-14.
../images/485437_1_En_4_Chapter/485437_1_En_4_Fig14_HTML.jpg
Figure 4-14

Buffering progress bars without values

Notifications

Notifications are a visual aid to attract the attention of the users. At times, they prompt the users to complete an action; sometimes they may be used to show important/helpful information to the users. Updates/alerts are types of notifications, while push subscription messages/context pop-ups are other use cases usually found in modern layouts.

Bulma’s notification element is quite easy to code, as shown in Listing 4-15.
<div class="columns is-multiline">
   <div class="column is-5 notification is-primary">
   <button class="delete"></button>
    cat ipsum dolor sit amet, eos...
   </div>
   <div class="column is-5 is-offset-1 notification is-link">
   <button class="delete"></button>
    cat ipsum dolor sit amet, eos...
   </div>
   <div class="column is-half is-offset-2 notification">
   <button class="delete"></button>
    cat ipsum dolor sit amet, eos...
   </div>
</div>
Listing 4-15

Creating Basic Notifications

In Listing 4-15, we first create a columns container and assign the is-multiline class in conjunction with the columns class. Then we define three columns of different sizes. Inside each <div> element column, we use the notification class and also create a delete button for those notifications by using the delete class for each <button> element.

The first column occupies the space of five columns, whereas the second column is allocated a space of five columns and is offset by one column. The third column is assigned the space of half the 12-column grid and is assigned an offset of two columns. While the first notification is assigned a primary contextual color, the second notification is assigned the link contextual color using the is-primary and is-link classes, respectively. The third notification is not assigned any color and will take up the default color for the notification attribute.

The output of the code on a tablet screen is shown in Figure 4-15.
../images/485437_1_En_4_Chapter/485437_1_En_4_Fig15_HTML.jpg
Figure 4-15

Different colored notification columns with the delete button

Images

Bulma’s image element is a container for responsive images or pictures. Bulma’s image element can not only be used for creating rounded and Retina images but also for defining ratio-based responsive images—for example, images used in still photography displayed consistently on various devices/screen-sizes.

To understand Bulma’s image component, let’s look at the Listing 4-16.
<figure class="image is-48x48">
  <img src="Images/Shrek.png" alt="Shrek">
 </figure>
<br><br><br>
<figure class="image is-128x128">
  <img src="Images/Shrek.png" alt="Shrek">
</figure>
Listing 4-16

Creating Two Different Image Sizes for the Same Picture

In Listing 4-16, we use two <figure> tags for the same image, with the image class assigned to each of them. We use the <img> tag for defining the source of the image. While the first image is assigned a size of 48×48 using the is-48×48 class, the second image is assigned a size of 128×128 using the is-128×128 class in conjunction with the image class.

The output of the code is seen in Figure 4-16.
../images/485437_1_En_4_Chapter/485437_1_En_4_Fig16_HTML.jpg
Figure 4-16

Same image with different sizes

You can add a rounded shape to the image, as shown in Listing 4-17.
<figure class="image is-128x128">
  <img class="is-rounded" src="Images/Shrek.png" alt="Shrek">
</figure>
Listing 4-17

Defining a Rounded Image Container

In Listing 4-17, we use the <figure> tag and assign a size of 128×128 to the image. Next, for the <img> tag, we assign the is-rounded class, which gives a rounded border shape to the image.

The output of the code is shown in Figure 4-17.
../images/485437_1_En_4_Chapter/485437_1_En_4_Fig17_HTML.jpg
Figure 4-17

Rounded border image

If you do not know the exact dimensions, you can still define a ratio for the images.

Bulma has the following 16 ratio modifiers for the image element:
  • image is-square

  • image is-1by1

  • image is-5by4

  • image is-4by3

  • image is-3by2

  • image is-5by3

  • image is-16by9

  • image is-2by1

  • image is-3by1

  • image is-4by5

  • image is-3by4

  • image is-2by3

  • image is-3by5

  • image is-9by16

  • image is-1by2

  • image is-1by3

Let’s see an example of a ratio modifier using the image element in Listing 4-18.
<figure class="image is-3by2">
  <img src="Images/Fiona.png" alt="Fiona">
</figure>
Listing 4-18

Creating Ratio Modifier-Based Image Containers

In Listing 4-18, we use the <figure> tags and use the is-3by2 ratio modifier class in conjunction with the image class. Then we define the image source using the <img> tag.

The output of the code is seen in Figure 4-18.
../images/485437_1_En_4_Chapter/485437_1_En_4_Fig18_HTML.jpg
Figure 4-18

Image ratio modifier (3by2)

Tags

In blogs you may see tags, which are labels that are relevant to that article. It is a handy element in today’s digital design era, especially used in digital photos programs, web pages, blogs, articles, and social media platforms.

A particular use case is in blogs where you promote your products/goods. You will use relevant tags to increase the scope of the product. But your site visitors/users may come out with different tags, which may be market-based, location-based, or context-based. For example, consider a blog on a datacenter. You may use tags like “Data-Center operations,” “Digital Datacenters,” and “Innovation-in-Datacenters” for your company blog/article. Your users/customers/readers may add tags like “colocation,” “digital transformation,” “IoT,” “DCIM,” “Sustainability,” “Data-center Planning,” and “Data-center-Energy-Efficiency” or even their company name to increase the reach and exposure of their solutions/concepts.

To understand how to use the tag component in Bulma, let’s look at Listing 4-19.
<div class="box">
<p class="has-text-centered">
<span class="tag is-primary">WhatsApp</span>
<span class="tag is-link">Facebook</span>
<span class="tag is-success">Share</span>
</p>
</div>
Listing 4-19

Basic Tags with Different Contextual Colors

In Listing 4-19, we create a box container within which we define a paragraph tag <p> and assign the has-text-centered class to it so that the output is centered. Then we create three tags using the tag class. We enclose it in three <span> elements and after assigning the tag class to each <span> element, we assign different contextual colors—primary, link, and success—to the three <span> elements, respectively.

The output of the code is shown in Figure 4-19.
../images/485437_1_En_4_Chapter/485437_1_En_4_Fig19_HTML.jpg
Figure 4-19

Tags with different contextual colors

You can also assign rounded borders to the tags by using is-rounded in conjunction with the tag class. For example, check out Listing 4-20.
<div class="box">
<p class="has-text-centered">
<span class="tag is-rounded is-warning">Snapchat</span>
<span class="tag is-rounded is-danger">YouTube</span>
<span class="tag is-rounded is-info">Twitter</span>
</div>
Listing 4-20

Defining Rounded Tags

The code in Listing 4-20 is almost the same as that in Listing 4-19, but it uses the is-rounded class in conjunction with the tag and contextual color classes.

The output of the code is shown in Figure 4-20.
../images/485437_1_En_4_Chapter/485437_1_En_4_Fig20_HTML.jpg
Figure 4-20

Rounded tags

You can also use the medium and large classes to increase the size of the tags. Check out Listing 4-21.
<div class="box">
<div>
<span class="tag is-success">Share</span>
<span class="tag is-warning">Snapchat</span>
</div>
<br><hr><br>
<div class="tags are-medium">
<span class="tag is-primary">WhatsApp</span>
<span class="tag is-link">Facebook</span>
</div>
<br><hr><br>
<div class="tags are-large">
<span class="tag is-danger">YouTube</span>
<span class="tag is-info">Twitter</span>
</div>
</div>
Listing 4-21

Defining Different Sizes for the Tags

In Listing 4-21, we create a box container and define three <div> elements. Within the first <div> tags, we create two <span> elements, and assign the tag class with different contextual color classes.

Then we create another <div> and we assign the tags are-medium class to it.

Within this <div> tag, we create two <span> elements and assign the tag class in conjunction with the contextual color classes.

Moving forward, we create a third <div> element and assign the are-large class to it.

Then we similarly create two <span> elements and assign the contextual classes to them in conjunction with the tag class.

The output of the code is shown in Figure 4-21.
../images/485437_1_En_4_Chapter/485437_1_En_4_Fig21_HTML.jpg
Figure 4-21

Different sized tags

You can also attach two tags together. Check out the code example in Listing 4-22.
<div class="box">
<div class="tags has-addons">
<span class="tag is-success">Share</span>
<span class="tag is-warning">Snapchat</span>
</div>
<br>
<div class="tags has-addons are-medium">
<span class="tag is-primary">WhatsApp</span>
<span class="tag is-link">Facebook</span>
</div>
<br>
<div class="tags has-addons are-large">
<span class="tag is-danger">YouTube</span>
<span class="tag is-info">Twitter</span>
</div>
</div>
Listing 4-22

Tag Addon Feature Combining Both Tags

The Listing 4-22 code is the same as in Listing 4-21, where we create three <div> elements with normal, medium, and large classes assigned to them. Also, we create two <span> elements for creating two tags in each <div> section.

The only difference is in each <div> element, to which we assign the tags has-addons class to attach the two tags.

The output of the code is shown in Figure 4-22.
../images/485437_1_En_4_Chapter/485437_1_En_4_Fig22_HTML.jpg
Figure 4-22

Addons feature attaching two tags

You can also append the delete button or create a delete tag. Check Listing 4-23.
<div class="box">
<div class="tags has-addons are-medium">
<span class="tag is-success">Share</span>
<span class="tag is-warning">Snapchat
<button class="delete"></button>
</span>
</div>
<div class="tags has-addons are-medium">
<span class="tag is-primary">WhatsApp</span>
<span class="tag is-link">Facebook</span>
<a class="tag is-delete"></a>
</div>
Listing 4-23

Appending Delete Button and Delete Tag

In Listing 4-23, we create a box container to house two <div> sections where we create medium-sized tags and attach two tags under each <div> element.

To the first <div>, we assign the tags has-addons class in conjunction with the are-medium class. We create two tags using <span> elements. Then we use a <button> element and assign the delete class to it.

For the second <div>, we create two medium-sized attached tags the same way. However, in this <div>, instead of the button element, we use an <a> anchor link tag and assign the tag is-delete class to it.

The output of the code is shown in Figure 4-23.
../images/485437_1_En_4_Chapter/485437_1_En_4_Fig23_HTML.jpg
Figure 4-23

Delete button and delete tag appended, respectively

You can create a list of tags and group several tags containers together using the field is-grouped class for the main <div> container. If the list of tags containers extends more than the 12-column grid, you need to use the is-grouped-multiline class as shown in Listing 4-24.
<strong class="box">
<div class="field is-grouped is-grouped-multiline">
  <div class="control">
    <div class="tags has-addons">
      <a class="tag is-success">Data Centers</a>
      <a class="tag is-delete"></a>
    </div>
  </div>
  <div class="control">
    <div class="tags has-addons">
      <a class="tag is-success">Digital transformation</a>
      <a class="tag is-delete"></a>
    </div>
  </div>
  <div class="control">
    <div class="tags has-addons">
      <a class="tag is-success">Energy-Efficiency</a>
      <a class="tag is-delete"></a>
    </div>
  </div>
  <div class="control">
    <div class="tags has-addons">
      <a class="tag is-success">Critical Power</a>
      <a class="tag is-delete"></a>
    </div>
  </div>
  <div class="control">
    <div class="tags has-addons">
      <a class="tag is-success">IT Infrastructure</a>
      <a class="tag is-delete"></a>
    </div>
  </div>
  <div class="control">
    <div class="tags has-addons">
      <a class="tag is-success">DC Power</a>
      <a class="tag is-delete"></a>
    </div>
  </div>
  <div class="control">
    <div class="tags has-addons">
      <a class="tag is-success">Emerson Network Power</a>
      <a class="tag is-delete"></a>
    </div>
  </div>
  <div class="control">
    <div class="tags has-addons">
      <a class="tag is-success">Power Distribution</a>
      <a class="tag is-delete"></a>
    </div>
  </div>
  <div class="control">
    <div class="tags has-addons">
      <a class="tag is-success">Edge Computing</a>
      <a class="tag is-delete"></a>
    </div>
  </div>
  <div class="control">
    <div class="tags has-addons">
      <a class="tag is-success">UPS</a>
      <a class="tag is-delete"></a>
    </div>
  </div>
  <div class="control">
    <div class="tags has-addons">
      <a class="tag is-success">Hyper-Converged Infrastructure</a>
      <a class="tag is-delete"></a>
    </div>
  </div>
 </div>
</strong>
Listing 4-24

Grouped List of Tags with Multiline Output

In Listing 4-24, we create a box container and create a parent <div> element and assign the field is-grouped and the is-grouped-multiline classes to it.

Then we create multiple several <div> containers. In each <div> child container, we create subchild <div>s and assign the control class to them. Next, we create attached tags using the tags has-addons class and create two anchor links, where we create each contextual color tag and append with the delete tag.

We create several <div> elements with the control class, and within them we append two tags using the process mentioned earlier.

The output of the code is shown in Figure 4-24.
../images/485437_1_En_4_Chapter/485437_1_En_4_Fig24_HTML.jpg
Figure 4-24

Grouped tags container

The output in Figure 4-24 has a look similar to the tags used in corporate blogs or on the LinkedIn portal among other platforms.

Pagination

Pagination is quite useful in segregation of content in multiple pages and indicates the toggling effect, helping users find the specific content easily. It prevents users from getting overwhelmed with content overload and divides the content into discrete pages, resulting in remarkable readability. Thus, pagination helps reduce complexities and enhances content exploration in a well-organized way.

Bulma has a responsive pagination module, an example of which can be seen in Listing 4-25.
<nav class="pagination" role="navigation">
  <a class="pagination-previous">Previous</a>
  <a class="pagination-next">Next page</a>
  <ul class="pagination-list">
    <li>
      <a class="pagination-link">1</a>
    </li>
    <li>
      <span class="pagination-ellipsis">&hellip;</span>
    </li>
    <li>
      <a class="pagination-link">4</a>
    </li>
    <li>
      <a class="pagination-link is-current">5</a>
    </li>
 </nav>
Listing 4-25

Creating a Simple Pagination Module

In Listing 4-25, to create the pagination, we initially create a navigation <nav> element and assign a pagination class to it. Then we create two links and assign the pagination-previous and pagination-next classes to it, respectively.

Then we create the pagination buttons by using an unordered list. The parent <ul> tag is assigned the pagination-list class. Within the <ul> element, we create the list items using anchor <a> tags.

First, we create an anchor link <a> and assign the pagination-link class to it. We also assign the is-current class to it to make it look like the current page. We assign 1 as the starting number of the page.

Then we create the second <li> tag and use a <span> element and assign the pagination-ellipsis class to it. The ellipsis creates dots, which is the range separator. Within the <span> tags, we insert the &hellip; to complete the functionality of the ellipsis.

We move on to create the third anchor link tag and assign the pagination-link class to it and enter the page number as 4. Similarly, we create another pagination list item and name it as 5 for the page number.

The output of the code is shown in Figure 4-25.
../images/485437_1_En_4_Chapter/485437_1_En_4_Fig25_HTML.jpg
Figure 4-25

Normal pagination

Bulma has integrated small, medium, and large sizes for the pagination feature shown in Listing 4-26.
<nav class="pagination is-small" role="navigation">
  <a class="pagination-previous">Previous</a>
  <a class="pagination-next">Next page</a>
  <ul class="pagination-list">
    <li>
      <a class="pagination-link">1</a>
    </li>
    <li>
      <span class="pagination-ellipsis">&hellip;</span>
    </li>
    <li>
      <a class="pagination-link">4</a>
    </li>
    <li>
      <a class="pagination-link is-current">5</a>
    </li>
 </nav>
 <br><br>
 <nav class="pagination is-medium" role="navigation">
  <a class="pagination-previous">Previous</a>
  <a class="pagination-next">Next page</a>
  <ul class="pagination-list">
    <li>
      <a class="pagination-link">1</a>
    </li>
    <li>
      <span class="pagination-ellipsis">&hellip;</span>
    </li>
    <li>
      <a class="pagination-link">4</a>
    </li>
    <li>
      <a class="pagination-link is-current">5</a>
    </li>
 </nav>
 <br><br>
 <nav class="pagination is-large" role="navigation">
  <a class="pagination-previous">Previous</a>
  <a class="pagination-next">Next page</a>
  <ul class="pagination-list">
    <li>
      <a class="pagination-link">1</a>
    </li>
    <li>
      <span class="pagination-ellipsis">&hellip;</span>
    </li>
    <li>
      <a class="pagination-link">4</a>
    </li>
    <li>
      <a class="pagination-link is-current">5</a>
    </li>
 </nav>
Listing 4-26

Creating Different-Sized Pagination Modules

The code example in Listing 4-26 for creating the pagination is the same as in Listing 4-25.

Instead of a single <nav> element, we create three separate <nav> elements. The first <nav> element is assigned the pagination is-small class (instead of the pagination class in default size) to create a small-sized pagination feature.

For medium-sized and large-sized pagination output, we use the pagination is-medium and pagination is-large classes for the second and third <nav> elements, respectively.

The output of the code is shown in Figure 4-26.
../images/485437_1_En_4_Chapter/485437_1_En_4_Fig26_HTML.jpg
Figure 4-26

Small-, medium-, and large-sized pagination components

You can change the alignment of the pagination component. You can center it or align it to the right. Apart from that, you can also use the disabled attribute to disable a link. You can also create rounded pagination components by using the is-rounded class.

Let’s go to Listing 4-27 to understand it better.
<nav class="pagination is-rounded is-right" role="navigation">
  <a class="pagination-previous" disabled>Previous</a>
  <a class="pagination-next">Next page</a>
  <ul class="pagination-list">
    <li>
      <a class="pagination-link is-current">1</a>
    </li>
    <li>
      <span class="pagination-ellipsis">&hellip;</span>
    </li>
    <li>
      <a class="pagination-link">4</a>
    </li>
    <li>
      <a class="pagination-link">5</a>
    </li>
 </nav>
 <br><hr><br>
 <nav class="pagination is-rounded is-centered" role="navigation">
  <a class="pagination-previous" disabled>Previous</a>
  <a class="pagination-next">Next page</a>
  <ul class="pagination-list">
    <li>
      <a class="pagination-link is-current">1</a>
    </li>
    <li>
      <span class="pagination-ellipsis">&hellip;</span>
    </li>
    <li>
      <a class="pagination-link">4</a>
    </li>
    <li>
      <a class="pagination-link">5</a>
    </li>
 </nav>
Listing 4-27

Pagination Modules with Different Alignment and Rounded Shape

In Listing 4-27, the process to create the pagination is the same. The specific difference is that for the first <nav> element, we assign the is-rounded class in conjunction with the pagination class for defining the rounded shape for the pagination component. Thereon, we also assign the is-right class, which will align the pagination component to the right of the web page.

Then, in the first <a> element with the pagination-previous class, we add the disabled attribute to show that the link is disabled. The rest of the code is the same as that for the pagination components in the earlier examples.

Once we are done with the first pagination component, we create the second pagination component using another <nav> element. We assign the pagination is-rounded class to this <nav> tag. Here, in conjunction with the pagination is-rounded class, we assign an is-centered class to align the pagination component to the center. We also use the disabled attribute in the first anchor tag akin to the previous navigation element resulting in a grayed-out look for the link.

The rest of the code is the same as that of the first <nav> element or the earlier examples.

The output of the code is shown in Figure 4-27.
../images/485437_1_En_4_Chapter/485437_1_En_4_Fig27_HTML.jpg
Figure 4-27

Pagination components to the right and center, respectively

In Figure 4-27, you can see that the first pagination component is aligned to the right. The Previous & Next page labels are shifted to the left due to this alignment. In addition, the Previous label is grayed-out due to the disabled attribute.

As for the second pagination component, the alignment is to the center. Here, the Previous & Next page labels are on opposite ends of the page. Both these screenshots are taken on a tablet-sized screen.

Summary

In this chapter, we looked at navigation elements and media components. In the next chapter, you will learn about buttons, icons, modals, and forms, enabling you to build sophisticated, interactive web pages with ease.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.119.66