Reference
Every option the modal extension accepts.
The complete modal configuration: the container div, the toggle and dismiss shortcodes, the link forms, every dialog option, and the validation rules.
Enabling the filter
filters:
- modalThe container
A div whose identifier starts with modal- becomes a dialog.
::: {#modal-example description="modal-example-note" size=lg}
## The title
The body.
---
The footer.
:::| Part | Comes from |
|---|---|
| Title | The first heading in the div. |
| Body | Everything between the heading and the first horizontal rule. |
| Footer | Everything after the first horizontal rule, if there is one. |
Important
The modal- prefix is required. A div carrying modal attributes without it is left alone, and the extension warns, since that is nearly always a typo rather than an intention.
Dialog options
The same names work as project or document metadata, and as attributes on an individual container, where they win.
extensions:
modal:
size: lg
fade: true
centred: true| Option | Type | Default | Description |
|---|---|---|---|
size |
string | Dialog width. sm, lg, xl, or the aliases small, medium, default, large, extra-large, xlarge. |
|
fullscreen |
string | false |
true for always fullscreen, or a breakpoint (sm, md, lg, xl, xxl) for fullscreen below it. |
centred |
boolean | false |
Centres the dialog vertically. |
scrollable |
boolean | false |
Scrolls the body rather than the page when the content overflows. |
fade |
boolean | false |
Fades the dialog in and out. |
backdrop-static |
boolean | false |
Keeps the modal open when the backdrop is clicked. |
keyboard |
boolean | true |
Allows Esc to close the modal. |
Caution
centred is spelled the British way, and only that spelling reaches the dialog. centered written on its own is read as an ordinary attribute and does nothing, with no warning; written alongside centred it warns and is discarded.
Container-only attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
description |
string | The identifier of an element elsewhere in the document that describes this modal, wired up as aria-describedby. |
|
close-button |
boolean | true |
Whether the header carries a close button. |
close-button-label |
string | Close |
The aria-label of that close button. |
Validation
| Rule | On failure |
|---|---|
size is a known token or alias. |
Warns, and the default width is used. |
fullscreen is true, false, or a breakpoint. |
Warns, and the modal is not fullscreen. |
description names an identifier that exists in the document. |
Warns, and the attribute is still written. |
| A modal contains no other modal. | Warns. Bootstrap does not support nesting, and focus and backdrop handling break. |
A div with modal attributes carries the modal- prefix. |
Warns, and the div is left as an ordinary div. |
centred and centered are not both set. |
Warns, and centred is used. |
Limitations
- HTML with JavaScript and Bootstrap only. Where Bootstrap is absent the container stays an ordinary div, content and all, and the buttons render nothing.
- Modals cannot be nested, which is a Bootstrap constraint rather than an extension one.
- A modal needs a heading to take its title from, and a horizontal rule to separate a footer from the body.