modal(), modal_button() html()
A modal dialog (header, body, footer) and the button that opens it.
html()->modal($extra = [])
html()->modal_button($text = '', $id = '', $extra = [])Options
| Option | Meaning |
|---|---|
id | Id of the dialog; default modal_<n>. |
header, body, footer | Developer HTML (not escaped). |
show_close, inline, style | Close button; draw it in the page (as here) instead of hidden; inline style. |
size, fullscreen, centered, scrollable, static, fade, theme | Bootstrap 5 options: sm / lg / xl, true or a breakpoint, vertical centre, scrolling body, no close on backdrop clicks, animation, data-bs-theme. |
modal_button($text, $id, $extra) | A button() that opens the dialog $id. |
Example
Code
return html()->modal([
'inline' => 1,
'show_close' => 1,
'header' => 'Modal header',
'body' => '<p>Some body</p>',
'footer' => form_item()->save(),
])
. html()->modal(['id' => 'docs-ref-confirm', 'header' => 'Delete?', 'body' => '<p>The item goes to the bin.</p>', 'show_close' => 1, 'centered' => 1])
. '<p>' . html()->modal_button('Open a dialog', 'docs-ref-confirm', ['type' => 'danger']) . '</p>';Notes
- The first dialog is drawn inline so the page shows it; a real one is hidden until its button opens it.
Bootstrap 3 and 5
Bootstrap 3: data-toggle="modal", .close; Bootstrap 5: data-bs-toggle, .btn-close, and the B5 options; Tailwind CSS (tw): daisyUI's modal / modal-box from the class map, opened by the yf_tw bridge (size, fullscreen, static, inline). Bootstrap 3 modals, Bootstrap 5 modal.
See also: html/offcanvas, html/button