September 30, 2022

Robotic Notes

All technology News

A Simple and Intuitive CSS Framework

3 min read

According to its official website, Bulma is a free, open source framework that provides ready-to-use frontend components that you can easily combine to build responsive web interfaces.

In this article, let’s take a look at the basics of Bulma and how to build a simple To-Do App using this CSS framework.

Why Use Bulma

Bulma adopts a mobile-first approachwhich ensures that UI components would be responsive and looks great in small screens.

It is, at its core, a CSS framework similar to Tailwind CSS and Material UI, so it provides many pre-styled components without JavaScript included. Hence, according to its GitHub documentation, Bulma is “environment agnostic”, as it’s just the style layer on top of the logic. With Bulma, you can simply focus on the styles.

Bulma is very easy to install and learn. It has intuitive, readable modifiers, syntax and classes.

Getting Started

The 2 ways I recommend to use Bulma in your projects are:

1. Via npm or yarn

2. Via CDN

1<link rel="stylesheet" href="">

Starter Template

On Bulma’s website, we can also copy the starter HTML template below to our project. As you can see, the starter template imports Bulma via CDN.

1<!DOCTYPE html>


3 <head>

4 <meta charset="utf-8">

5 <meta name="viewport" content="width=device-width, initial-scale=1">

6 <title>Hello Bulma!</title>

7 <link rel="stylesheet" href="">

8 </head>

9 <body>

10 <section class="section">

11 <div class="container">

12 <h1 class="title">

13 Hello World

14 </h1>

15 <p class="subtitle">

16 My first website with <strong>Bulma</strong>!

17 </p>

18 </div>

19 </section>

20 </body>


If we open this HTML template, we get the following webpage:

Layout / Spacing

As seen in the starter template, the most common layouts are the .container and .section classes. Using these classes would automatically provide some default margins or padding.

Use the spacing helpers to customize margin and paddings.

Syntax modifier

Font Sizes Example

In Bulma, the modifier syntax is pretty straightforward. They are often in the is-* or the has-* format. For example, to adjust font sizes, we use is-size-[number] or is-[number].

1<p class="title is-1">Title 1</p>

2<p class="subtitle is-3">Subtitle 3</p>


4<p class="title is-2">Title 2</p>

5<p class="subtitle is-4">Subtitle 4</p>


7<p class="title is-3">Title 3</p>

8<p class="subtitle is-5">Subtitle 5</p>


Font Styles Example

For font styles, it is simply is-[style].

1<h1 class="title">Hello World</h1>

2<h1 class="title is-uppercase">Hello World</h1>

3<h1 class="title is-italic">Hello World</h1>

4<h1 class="title has-text-weight-bold">Hello World</h1>

5<h1 class="title has-text-weight-light">Hello World</h1>


More details can be found in the documentation.

Text Colors Examples

With changing the text colors, Bulma contains the common classes you will find in other CSS libraries such info, primary, success and so on. The modifier syntax will be has-text-[style].

1<h1 class="title has-text-primary">Hello World</h1>

2<h1 class="title has-text-dark">Hello World</h1>

3<h1 class="title has-text-link">Hello World</h1>

4<h1 class="title has-text-info">Hello World</h1>

5<h1 class="title has-text-success">Hello World</h1>

6<h1 class="title has-text-warning">Hello World</h1>

7<h1 class="title has-text-danger">Hello World</h1>


More details can be found in the documentation.

A Simple To-Do App via Bulma

Now that we’ve learned the basics of Bulma, let’s create a simple to-do app. I will be using the Panel component and start from there.

Step 1: Import Bulma

First, let’s import Bulma via CDN into our html file.

1<!DOCTYPE html>

2<html lang="en">


4 <meta charset="UTF-8">

5 <meta http-equiv="X-UA-Compatible" content="IE=edge">

6 <meta name="viewport" content="width=device-width, initial-scale=1.0">

7 <title>Bulma To-Do App</title>

8 <link rel="stylesheet" href="">






Step 2: Add the components

Inside bodyI will add the following:

1<section class="section">

2 <div class="container">

3 <h1 class="title">

4 Bulma To-Do List

5 </h1>

6 <nav class="panel">

7 <p class="panel-heading">To-Do Items</p>

8 <div class="panel-block">

9 <p class="control">

10 <input class="input" type="text" placeholder="Add To-Do">

11 </p>

12 <button class="button is-link">Add</button>

13 </div>

14 <label class="panel-block">

15 <input type="checkbox">

16 Buy food

17 </label>

18 <label class="panel-block">

19 <input type="checkbox">

20 Do laundry

21 </label>

22 <label class="panel-block">

23 <input type="checkbox">

24 Water plants

25 </label>

26 </nav>

27 </div>

28 </section>

As seen in the code above, it is quite intuitive and easy to understand, even if you’re unfamiliar with Bulma. Simply refer to its documentation for the Panel component to understand it. We should now have a nice-looking and simple to-do list.


Step 3: Add index.js

Create a file called index.js so we can add items to this list. In this script, we will add a click eventListener to our button and insert a new one panel-block component with the value of the user’s input. Finally, we will clear the text input after the component is added.

1const btn = document.querySelector(".button");

2const input = document.querySelector(".input");

3const panel = document.querySelector(".panel");


5btn.addEventListener("click", function() {


7 if (input.value === "") {

8 return alert("Please enter a value");

9 }


11 const htmlStr = `<label class="panel-block">

12 <input type="checkbox">${input.value}</label>`;


14 panel.insertAdjacentHTML("beforeend", htmlStr);


16 input.value = "";



And here’s the result of our simple to-do app!

Open Source Session Replay

Debugging a web application in production may be challenging and time-consuming. OpenReplay is an Open-source alternative to FullStory, LogRocket and Hotjar. It allows you to monitor and replay everything your users do and shows how your app behaves for every issue. It’s like having your browser’s inspector open while looking over your user’s shoulder. OpenReplay is the only open-source alternative currently available.


Happy debugging, for modern frontend teams – Start monitoring your web app for free.


Bulma offers a quick and easy solution for front-end developers. It offers a highly flexible, responsive and intuitive CSS library.

There are also many ways to customize the styles, which are documented in detail here. Thanks for reading the article. I hope it has been helpful in getting you started with Bulma. Cheers!


Source link