--- 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 %}
1
2
3
4
5
{% endcapture %} {% capture only_button %} // Load Bulma's base styles and themes (including the minireset) @use "bulma/sass/base"; @use "bulma/sass/themes"; // Load the button and title elements and compnents @use "bulma/sass/elements/button"; @use "bulma/sass/elements/title"; @use "bulma/sass/components/message"; {% endcapture %} {% capture buttons %} {% endcapture %} {% capture use_rule %} @use "path/to/file.scss"; {% endcapture %} {% capture base_loads %} // Load Bulma's base styles and themes (including the minireset) @use "bulma/sass/base"; @use "bulma/sass/themes"; // Load other Bulma components @use "bulma/sass/elements/button"; @use "bulma/sass/components/message"; {% endcapture %}

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:

{% 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 %}