Bulma CSS Framework
Bulma is a modern, open-source CSS framework built entirely on Flexbox, providing a responsive and mobile-first design system. Currently at version 1.0.4, it undergoes active development with frequent bug fixes and feature enhancements, as evidenced by multiple patch releases within the 1.x series. A key differentiator is its "CSS only" philosophy, meaning it ships without any JavaScript, allowing developers to integrate their preferred front-end logic. It focuses solely on the styling layer, making it "environment agnostic." Bulma offers a comprehensive set of CSS components and utilities, and while it provides a compiled `bulma.css` file, it is highly customizable through its Sass source files, particularly since its rewrite in v1.0.0 to use Dart Sass. The framework is designed for ease of use, maintaining consistent HTML snippets across major versions to simplify upgrades.
Common errors
-
Error: File to import not found or unreadable: bulma/sass/utilities/mixins.sass
cause Attempting to import Sass placeholders from the deprecated `utilities/mixins` path after Bulma v0.9.2.fixChange `@import 'bulma/sass/utilities/mixins.sass';` to `@import 'bulma/sass/utilities/extends.sass';` for placeholders, or rely on importing `bulma/bulma.sass` directly. -
Error: @use rules must be written at the top of the file. (Dart Sass)
cause Using an outdated Sass compiler or incorrect syntax when trying to compile Bulma's Dart Sass-based source files after v1.0.0.fixEnsure your project uses a recent version of Dart Sass (the `sass` npm package) for compilation and review your custom Sass files for any syntax incompatibilities. -
Module not found: Error: Can't resolve 'bulma/css/bulma.css'
cause Your module bundler (e.g., Webpack, Rollup) cannot locate the Bulma CSS file within `node_modules`.fixVerify `npm install bulma` completed successfully. Ensure your bundler configuration includes appropriate loaders (e.g., `css-loader` and `style-loader` for Webpack) and path resolvers to locate files within `node_modules`. -
Deprecation Warning: This module is deprecated: please use 'sass/helpers/_all.sass' instead.
cause You are importing the deprecated `base/helpers.sass` file, which was superseded in Bulma v0.9.0.fixUpdate your Sass imports from `@import 'bulma/sass/base/helpers.sass';` to `@import 'bulma/sass/helpers/_all.sass';`.
Warnings
- breaking Bulma v1.0.0 was a full rewrite of the framework using Dart Sass. While HTML markup remains consistent, projects extensively customizing Bulma via Sass should ensure their build pipeline uses Dart Sass and review custom Sass for compatibility.
- breaking Sass placeholders (e.g., `%control`, `%unselectable`) were moved from `utilities/mixins` to `utilities/extends` to fix duplicate imports.
- deprecated The `base/helpers.sass` file and the `list` component (`components/list.sass`) were deprecated and removed.
- gotcha Bulma is a CSS-only framework and does not include any JavaScript. Interactive components (e.g., dropdowns, modals, navigation toggles) require a separate JavaScript implementation.
- gotcha Older 1.x versions (prior to 1.0.3) might have shown Sass 1.80 deprecation warnings related to global built-in functions.
- gotcha Helper classes might have been missing prefixes in earlier 1.x versions (prior to 1.0.3).
Install
-
npm install bulma -
yarn add bulma -
pnpm add bulma
Imports
- bulma.min.css
import 'bulma/css/bulma.min.css';
- bulma.sass
@import 'bulma';
@import 'bulma/bulma.sass';
- elements/button.sass
@import 'bulma/elements/button';
@import 'bulma/sass/elements/button.sass';
Quickstart
import 'bulma/css/bulma.min.css';
// For custom Sass, create a file like `src/styles/custom-bulma.scss`:
// $primary: #00d1b2; // A custom primary color
// @import 'bulma/bulma.sass';
// Then, import it here instead of `bulma/css/bulma.min.css`:
// import '../styles/custom-bulma.scss';
// This JavaScript demonstrates adding content that will be styled by Bulma.
// Ensure your HTML has a basic structure for Bulma classes to apply.
document.addEventListener('DOMContentLoaded', () => {
const root = document.createElement('div');
root.className = 'section';
root.innerHTML = `
<div class="container">
<h2 class="title is-2">Dynamic Content</h2>
<p class="content">This content was added dynamically using JavaScript, styled by Bulma.</p>
<button class="button is-danger">Dynamic Button</button>
<div class="columns is-mobile mt-4">
<div class="column is-half-mobile is-one-quarter-desktop">
<div class="box has-background-info-light">Column 1</div>
</div>
<div class="column is-half-mobile is-one-quarter-desktop">
<div class="box has-background-warning-light">Column 2</div>
</div>
</div>
</div>
`;
document.body.appendChild(root);
});