Modal

An example of a simple modal. This runs purely on the front-end with some simple CSS and JS.

Back to overview

Modal

Dialogs, sometimes called "modals", appear above the page and require the user's immediate attention. Users can always dismiss a modal via the "Escape" key or by clicking the ✕ icon.

JDK22.0.2 w/ Medusa 0.9.6-SNAPSHOT

Client

<button onclick="_M.openModal('modal-1')">Open Modal 1</button>
<button onclick="_M.openModal('modal-2')">Open Modal 2</button>

<m:modal id="modal-1" title="💡 Example with title">
    <p>This is a sample modal (1). This one has a title.</p>
    <p>Try pressing 'Esc' to close this.</p>
</m:modal>

<m:modal id="modal-2">
    <p>This is another sample modal (2). This one has <strong>no</strong> title.</p>
</m:modal>

Server

import io.getmedusa.medusa.core.annotation.UIEventPage;

@UIEventPage(path = "/detail/modal", file = "/pages/modal.html")
public class ModalController { }

Custom modal CSS

By default, Medusa comes with a simple pre-defined style. If you want to customize the CSS, you can simply define custom rules

The following classes are used: