Skip to content

Modal

The Modal component renders Bulma’s card-style modal. Toggle it by adding/removing .is-active on the modal’s id. A built-in script handles closing via data-modal-close attributes and clicking the background.

<Button
color="primary"
onclick="document.getElementById('my-modal').classList.add('is-active')"
>
Open modal
</Button>
<Modal id="my-modal" title="My modal">
<p>This is the modal body.</p>
</Modal>

The footer slot replaces the default Close button:

<Button
color="info"
onclick="document.getElementById('confirm-modal').classList.add('is-active')"
>
Open confirm dialog
</Button>
<Modal id="confirm-modal" title="Confirm action">
<p>Are you sure you want to delete this item?</p>
<Fragment slot="footer">
<Button type="button" color="danger" data-modal-close>Delete</Button>
<Button type="button" data-modal-close>Cancel</Button>
</Fragment>
</Modal>

Toggle visibility by toggling .is-active on the element with the modal’s id:

// Open
document.getElementById("my-modal").classList.add("is-active");
// Close
document.getElementById("my-modal").classList.remove("is-active");

Any element with data-modal-close inside the modal (or the backdrop) will close it automatically.

PropTypeDefaultDescription
idstringRequired. The modal element’s id.
titlestringRequired. Title shown in the modal header.
SlotDescription
defaultModal body content.
footerFooter content. Defaults to a Close button with data-modal-close.