--- title: With node-sass layout: documentation doc-tab: customize doc-subtab: node-sass breadcrumb: - home - documentation - customize - customize-node-sass --- {% capture init %} npm init {% endcapture %} {% capture step_1 %}

In your terminal, create a new folder called mybulma, navigate to it, then type the following command:

{% highlight bash %}{{ init }}{% endhighlight %}

This will launch an interactive setup to create package.json. When prompted for an entry point, enter sass/mystyles.scss.

{% endcapture %} {% capture dependencies %} npm install node-sass --save-dev npm install bulma --save-dev {% endcapture %} {% capture step_2 %}

You only need 2 packages to customize Bulma: node-sass and bulma itself.

{% highlight bash %}{{ dependencies }}{% endhighlight %} {% endcapture %} {% capture scss_bulma %} @charset "utf-8"; @import "../node_modules/bulma/bulma.sass"; {% endcapture %} {% capture step_3 %}

Create a sass folder in which you add a file called mystyles.scss:

{% highlight scss %}{{ scss_bulma }}{% endhighlight %}

Make sure to write the correct path to the bulma.sass file.

{% endcapture %} {% capture step_4 %}

Let's create an HTML template which uses several Bulma components.

{% highlight html %}{% include snippets/mypage.html %}{% endhighlight %}

Notice the css/mystyles.css path for your stylesheet. This will be the location of the CSS file we will generate with Sass.

{% include elements/responsive-image-2x.html path="customize/custom-bulma-01-unstyled" extension="png" alt="Bulma unstyled" width="600" height="300" %}
The unstyled page
{% endcapture %} {% capture scripts %} "scripts": { "css-build": "node-sass --omit-source-map-url sass/mystyles.scss css/mystyles.css", "css-watch": "npm run css-build -- --watch", "start": "npm run css-watch" } {% endcapture %} {% capture npm_build %} npm run css-build {% endcapture %} {% capture npm_build_success %} Rendering Complete, saving .css file... Wrote CSS to /path/to/mybulma/css/mystyles.css {% endcapture %} {% capture npm_watch %} npm start {% endcapture %} {% capture step_5 %}

To build a CSS file from a Sass file, we can use node scripts:

{% highlight html %}{{ scripts }}{% endhighlight %}

To test it out, go in your terminal and run the following command:

{% highlight bash %}{{ npm_build }}{% endhighlight %}
{% include elements/responsive-image-2x.html path="customize/custom-bulma-02-default" extension="png" alt="Bulma default styles" width="600" height="300" %}
Bulma's default styles

If set up correctly, you will see the following message:

{% highlight bash %}{{ npm_build_success }}{% endhighlight %}

To watch for changes, just launch the following command:

{% highlight bash %}{{ npm_watch }}{% endhighlight %} {% endcapture %} {% capture mystyles %} @charset "utf-8"; // Import a Google Font @import url('https://fonts.googleapis.com/css?family=Nunito:400,700'); // Set your brand colors $purple: #8A4D76; $pink: #FA7C91; $brown: #757763; $beige-light: #D0D1CD; $beige-lighter: #EFF0EB; // Update Bulma's global variables $family-sans-serif: "Nunito", sans-serif; $grey-dark: $brown; $grey-light: $beige-light; $primary: $purple; $link: $pink; $widescreen-enabled: false; $fullhd-enabled: false; // Update some of Bulma's component variables $body-background-color: $beige-lighter; $control-border-width: 2px; $input-border-color: transparent; $input-shadow: none; // Import only what you need from Bulma @import "../node_modules/bulma/sass/utilities/_all.sass"; @import "../node_modules/bulma/sass/base/_all.sass"; @import "../node_modules/bulma/sass/elements/button.sass"; @import "../node_modules/bulma/sass/elements/container.sass"; @import "../node_modules/bulma/sass/elements/form.sass"; @import "../node_modules/bulma/sass/elements/title.sass"; @import "../node_modules/bulma/sass/layout/hero.sass"; @import "../node_modules/bulma/sass/layout/section.sass"; {% endcapture %} {% capture step_6 %}

Replace the content of the mystyles.scss file with the following:

{% highlight scss %}{{ mystyles }}{% endhighlight %}

Since you are watching for changes, simply save the file to see the result:

{% include elements/responsive-image-2x.html path="customize/custom-bulma-03-styled" extension="png" alt="Bulma customized" width="600" height="300" %}
Bulma's customized theme
{% endcapture %} {% include components/step.html title='1. Create a package.json file' content=step_1 %}
{% include components/step.html title="2. Install the dev dependencies" content=step_2 %}
{% include components/step.html title="3. Create a Sass file" content=step_3 %}
{% include components/step.html title="4. Create an HTML page" content=step_4 %}
{% include components/step.html title="5. Add node scripts to build your CSS" content=step_5 %}
{% include components/step.html title="6. Add your own Bulma styles" content=step_6 %}