Bulma is a simple, elegant, and modern CSS framework that a lot of developers prefer over Bootstrap. Personally, I think Bulma has a better design by default, and it also feels more light-weight.
In this tutorial, I’ll give you a super quick introduction to the library.
We've also created a free Bulma course on Scrimba. Check it out here.
Setting up Bulma is super easy, and you can do it in several different ways, whether you prefer NPM, downloading it directly from the docs, or using a CDN. We’re just going to link to a CDN from our HTML file, like this:
This will give us access to the Bulma classes. And that’s actually all Bulma is: a collection of classes.
The first thing you should learn about Bulma is the modifier classes. These allow you to set alternative styles to almost all of the Bulma elements. They all start with
has-*, and then youreplace the
* with the style you want.
To understand this concept properly, let’s start off by looking at buttons.
To turn a normal button into a Bulma button, we’ll simply give it the class of
<button class="button">Click here</button>
Which results in the following style:
As you can see, it has a nice flat design by default. To change the styling, we’ll use Bulma modifiers. Let’s start off by making the button bigger, green, and with rounded corners:
<button class="button">Click here</button>
This code results is a pleasant-looking button:
You can also use modifiers to control the state of buttons. Let’s for example add the class
is-focused, which adds a border around it:
Finally, let’s also use one of the
has-* modifiers. These typically control what’s inside the element. In our case, the text. Let’s add
Here’s the result:
I’d recommend that you play around with combinations of the various classes in order to understand how flexible this system is. The combinations are almost endless. Check out the buttons section in the docs for more info.
At the core of any CSS framework is how they solve columns, as that’s relevant
for almost every website you’ll ever build. Bulma is based on Flexbox, so it’s
really simple to create columns. Let’s create a row with four columns.
First we’re creating a container
<div> with a class of
columns, and then we give each of the children a class of
column. It results in the following:
Note that you can add as many columns as you want. Flexbox takes care of dividing the space up equally between them.
To give the columns colors, we can replace the text inside them with a
<p> tag, and give it the
notification class and an
is-* modifier. Like this for example:
<p class="notification is-success">First column</p>
Let’s do this using the
is-danger modifiers, which results in the following:
notification class is actually meant for alerting users about something, as it allows you to fill the background with a color using the
is-* modifiers. Here it works well for separating the columns.
We can also easily control the width of a column. Let’s add the
modifier to the green column.
<p class="notification is-success">Second column</p>
Which results in the second column now occupying half the width, while the three other take up a third of the remaining half each.
Here are the options you can use for controlling the width of columns:
Finally, let’s also learn how to create a hero in Bulma. We’ll use the semantic
<section>, and give it a class of
is-info to give it some color. We also need to add a
<div> child with the class
In order to make this hero do something meaningful, we’re going to add a container element inside the body, and add a title and subtitle.
<div class="container"> <h1 class="title"> Primary title </h1> <h2 class="subtitle"> Primary subtitle </h2> </div>
Now it’s starting to look good! If we want it to be bigger, we can simply add
is-medium on the
<section> tag itself.
<section class="hero is-info is-medium"> ... </section>
And that’s it!
You’ve now gotten a basic taste of how Bulma works. And the best part is, the rest of the library is as intuitive and easy as the concepts you’ve seen up until now. So if you understand this, you’ll understand the rest of it without trouble.
So be sure to check out our free Bulma course if you want to learn the framework properly.
The practice of logging ranges from very simple static string statements to rich structured data events. In this article, we'll explore how logging in Python will give you a better view of what's going on in your application. In addition, I'll explore some best practices that will help you get the most value out of your logs.