---
title: Modularity in Bulma
layout: docs
theme: start
doc-tab: start
doc-subtab: modular
breadcrumb:
- home
- documentation
- start
- start-modular
---
{% capture import %}
// Only load the columns
@use "bulma/sass/grid/columns";
{% endcapture %}
{% capture columns %}
Bulma consists of elements and components defined in dozens of .scss
files, that you can load individually with the @use
keyword.
{% highlight sass %}{{ use_rule }}{% endhighlight %}
While this will correctly load the target file's styles, most Bulma components rely on base styles and CSS variables defined by the default themes.
That is why it's preferable to also load the sass/base
folder and the sass/themes
folder:
{% highlight sass %}{{ base_loads }}{% endhighlight %}
{% include docs/elements/anchor.html name="Importing columns" %}
Layout features like Bulma's columns don't rely on CSS variables defined by Bulma themes. As a result, you can load them directly without requiring any additional file.
For example, importing Bulma columns only requires to load the file located in the bulma/sass/grid
folder.
Simply load the columns.scss
file with the @use
keyword
{% highlight sass %}{{ import }}{% endhighlight %}
Now you can use the classes .columns
(for the container) and
.column
directly:
{% highlight html %}{{ columns }}{% endhighlight %}
{% include docs/elements/anchor.html name="Importing Bulma elements and components" %}
To load Bulma elements like the .button
and components like the .message
, it's preferable to also load the base styles and default themes.
{% highlight sass %}{{ only_button }}{% endhighlight %}
You can now use the .button
class, and all its modifiers:
-
.is-active
-
.is-primary
, .is-info
,
.is-success
...
-
.is-small
, .is-medium
,
.is-large
-
.is-outlined
, .is-inverted
,
.is-link
-
.is-loading
,
[disabled]
{% highlight html %}{{ buttons }}{% endhighlight %}
{% capture configuration %}
$section-padding: 3rem 1.5rem !default;
$section-padding-desktop: 3rem 3rem !default;
$section-padding-medium: 9rem 4.5rem !default;
$section-padding-large: 18rem 6rem !default;
{% endcapture %}
{% capture custom_section %}
// Load the section component with custom variables
@use "bulma/sass/layout/section" with (
$section-padding: 3rem,
$section-padding-desktop: 4.5rem
);
{% endcapture %}
{% include docs/elements/anchor.html name="Importing with custom Sass variables" %}
Most Bulma components are configured with Sass variables. For example, the .section
layout component uses 4 variables to define its padding:
{% highlight sass %}{{ configuration }}{% endhighlight %}
The @use
keyword allows use to configure a module when loading it with our own variables:
{% highlight sass %}{{ custom_section }}{% endhighlight %}