A StimulusJS controller for Bulma modals.
Switch branches/tags
Nothing to show
Clone or download
Stephen Dolan
Stephen Dolan v1.0.3
Latest commit 1685661 May 13, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Rename class May 11, 2018
.eslintrc.yml Initial commit May 11, 2018
.gitignore Initial commit May 11, 2018
.npmignore Initial commit May 11, 2018
LICENSE Initial commit May 11, 2018
README.md Remove references to old package that was used to create this one. May 12, 2018
package.json v1.0.3 May 12, 2018
webpack.config.js Initial commit May 11, 2018
yarn.lock Initial commit May 11, 2018


npm codebeat badge

Stimulus Bulma Modal

This is a simple StimulusJS controller that gives a Bulma Modal Component the ability to close itself and watches the DOM to intelligently turn background scrolling on and off.

JSFiddle Demo.


This assumes that StimulusJS and Bulma are already installed.

Add the stimulus-bulma-modal module:

$ yarn add stimulus-bulma-modal


$ npm install stimulus-bulma-modal

Basic Usage

First, register the controller with StimulusJS:

// application.js
import { Application } from 'stimulus';
import { BulmaModal } from 'stimulus-bulma-modal';

const application = Application.start();
application.register('modal', BulmaModal);

Next, you need to attach the controller to a Bulma modal. Because the controller operates within the modal, you'll need to add the is-active class somewhere in the DOM outside of the modal element.

<button onclick="openModal()">Open the modal from outside.</button>

<div data-controller="modal" class="modal">
  <div data-action="click->modal#close" class="modal-background"></div>
  <div class="modal-content">
    <div class="box has-text-centered">
      This is a great modal.
  <button data-action="click->modal#close" class="modal-close"></button>


Bug reports and pull requests are welcome on GitHub at https://github.com/stephendolan/stimulus-bulma-modal. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.


This package is available as open source under the terms of the MIT License.