Feedback
Modal
A dialog over the page, built on the native <dialog>: a centered box, a side panel (flyout) or a floating panel, with a title, a close button and focus kept inside while it is open. It opens from a trigger, a keyboard shortcut, JavaScript or the server. tk:modal.confirm is a ready-made "Are you sure?" dialog.
Nothing to show
Clicking Invite opens a centered white box over a dimmed page, with the title, the subtitle, the form and a close button in the top corner. The focus moves to the title. Escape, the close button or a click on the dimmed backdrop closes it, and the focus returns to Invite.
Opening from the server or from JavaScript #
Inside Livewire, $this->modal($name)->show() and ->close() open and close the modal of that name in this component; $this->modals()->close() closes every open modal. Outside Livewire, TALLKit::modal($name)->show() opens it on the next page rendered: the view this request returns, or the page after a redirect; ->close() undoes a show() of the same request, and TALLKit::modals()->close() drops every modal flashed in it. In JavaScript, tallkit.modal(name).show() and .close(). Inside the modal, Alpine expressions can call show() and close() for the modal they are in (x-on:click="close()").
Nothing to show
Side panel #
A full-height panel that slides in from the right edge (left in right-to-left pages), 25rem wide from md. position also takes left, top and bottom. floating is the same panel with a margin and rounded corners.
Nothing to show
Asking for confirmation #
The button opens a small dialog asking "Do you really want to delete this record?" with Cancel, focused, and a red Confirm. Confirm calls deleteProject and closes the dialog. The title, subtitle and both buttons can be changed with props and the cancel: and confirm: prefixes.
Nothing to show
Keyboard shortcut #
⌘K on macOS, Ctrl+K elsewhere, opens the modal from anywhere on the page. The shortcut is written with Alpine's key modifiers (ctrl.k, cmd.k, slash), plus mod, which is ⌘ on Apple platforms and Ctrl on the others. tk:kbd shortcut="mod.k" shows the same keys to the user. bare removes the box, padding and close button, for content that brings its own look.
Nothing to show
Edges and floating #
position puts the flyout panel on any edge: left, right, top or bottom. floating adds a margin and rounded corners.
Nothing to show
Sizes and backdrops #
size sets the text sizes, from xs to 3xl. backdrop is strong, subtle, ghost or false.
Nothing to show
Actions and content #
The modal passes actions, separator, prepend and append to its section; tk:modal.close is a button that closes the modal it is in.
Nothing to show
Not dismissible #
:dismissible="false" keeps the modal open on Escape and backdrop clicks; persist does the same and shakes the box.
Nothing to show
A trigger placed elsewhere #
tk:modal.trigger opens the modal with that name, wherever the modal is on the page.
Nothing to show
Confirming per row #
confirm takes the method with its arguments, and title changes the question.
Nothing to show
Events #
opened and closed fire on the dialog with the modal name. Here opened counts in Alpine.
Nothing to show
Customization #
Classes go to the <dialog>; prefixed attributes (section:, title:, close:) reach the parts inside.
Nothing to show
Reference
tk:modal
├── trigger (slot)
├── tk:modal.close
└── content
tk:modal.confirm
tk:modal.trigger
tk:modal
| Prop | Type | Default | Description |
|---|---|---|---|
name |
string | generated | The name used to open and close it from JavaScript or the server. |
title |
string | slot | null |
The heading, which names the dialog. |
subtitle |
string | slot | null |
Text under the title, which describes the dialog. |
description, prepend, append, actions, content, separator |
Passed to the inner section: text, content around the title, actions beside it, and a line under it (false by default). |
||
variant |
string | box | flyout (a panel along an edge), floating (the same with a margin), bare (no box, padding or close button), or the default centered box. |
position |
string | right |
For flyout and floating: left, right, top or bottom. |
size |
string | md |
xs, sm, md, lg, xl, 2xl or 3xl. Sets the text sizes. |
backdrop |
string | bool | dimmed | strong (almost black), subtle (light), ghost or false (none). |
closable |
bool | true (false with bare) |
Shows the close button. |
dismissible |
bool | true |
false keeps the modal open on Escape and backdrop clicks; it closes only from a close button or code. |
persist |
bool | string | false |
Like dismissible="false", but shakes the box on Escape or a backdrop click. A string is the CSS class of another animation. |
shortcut |
string | null |
A key combination that opens it, in Alpine's key modifier syntax: mod.k, ctrl.k, cmd.k, slash. mod is ⌘ on Apple platforms and Ctrl elsewhere. A shortcut without mod, ctrl, cmd, meta or alt is ignored while the user types in a field. |
trigger |
slot | null |
The element that opens the modal when clicked. |
Slots
| Slot | Description |
|---|---|
| default | The content. |
trigger |
The element that opens it. |
close |
Replaces the close button. |
title, subtitle, actions... |
As the props of the same name. |
Events
| Event | Detail | When |
|---|---|---|
opened |
{ name } |
The modal opened. |
closed |
{ name } |
The modal closed. |
Prefixes
| Prefix | Goes to |
|---|---|
trigger: |
The element around the trigger. |
close: |
The close button. |
section: |
The section inside the box, with its own prefixes (title:, subtitle:, content:...). |
title:, subtitle:, content:, actions:, separator:, list:, container:, icon*, badge* |
The same parts of the section, written without section:. |
tk:modal.confirm
| Prop | Type | Default | Description |
|---|---|---|---|
variant |
string | null |
delete changes the default texts and makes Confirm red. |
confirm |
string | null |
The Livewire method called by Confirm. |
cancel |
string | null |
The Livewire method called by Cancel. |
autoClose |
bool | true |
Closes the dialog when Confirm is clicked. false leaves it open, for the action to close it. |
title |
string | Are you sure? |
The question. |
subtitle |
string | Do you really want to proceed with this action? |
The explanation under it. |
actions |
slot | null |
Replaces the Cancel and Confirm buttons. |
size, description, prepend, append |
As on tk:modal. |
Every other attribute goes to the tk:modal (name, shortcut...). The default slot is the trigger.
Slots
| Slot | Description |
|---|---|
| default | The element that opens it. |
Events
| Event | Detail | When |
|---|---|---|
confirmed |
Confirm was clicked. Bubbles. |
Prefixes
| Prefix | Goes to |
|---|---|
actions:, cancel:, confirm: |
The row of buttons, Cancel and Confirm (confirm:label="Delete"). |
tk:modal.trigger and tk:modal.close
tk:modal.trigger opens the modal named by name when its content is clicked, and takes a shortcut; use it for a trigger placed away from the modal. tk:modal.close is a tk:button that closes the modal it is in. Any element with data-tallkit-modal-close does the same.
Events
Events are dispatched on the <dialog> and do not bubble: listen on the tag itself.
With Alpine:
Nothing to show
Customization
Classes and attributes on the tag go to the <dialog>. To reach the parts, prefix the attribute (listed in the Reference above).
Nothing to show
Accessibility
Follows the WAI-ARIA dialog pattern with the native modal <dialog>: the rest of the page is inert while it is open, the dialog is named by its title (aria-labelledby) and described by its subtitle (aria-describedby), and tk:modal.confirm has role="alertdialog". On opening, the focus goes to the element with autofocus, or else to the title; on closing, it returns to the element that opened it, or to the dropdown's trigger when the modal was opened from a menu item that is no longer shown.
| Key | Action |
|---|---|
| Tab / Shift+Tab | Moves through the controls inside the modal only. |
| Escape | Closes the modal (the innermost one, when modals are nested), unless dismissible is false or persist is set (with persist, the focus stays where it was). |
Behavior notes
- A modal inside another stays on top of it; Escape and clicks close only the innermost.
- The page does not scroll behind an open modal, and keeps its scrollbar space, so the layout does not jump.
- The dialog has
wire:ignore.self: a Livewire update does not close an open modal. - When a Livewire action redirects, the modals opened with
$this->modal()->show()in that request, by any component on the page, are flashed instead: the modal with that name on the next page opens when it loads. The same happens when a component redirects frommount(), for its modals and those of the parents still mounting. $this->modal()in a Livewire component targets only the modals that component renders, so two components can use the same name.TALLKit::modal()andtallkit.modal()target every modal with the name.- Toasts sent while a modal is open appear under its backdrop and cannot be used until it closes; for feedback inside the modal, use a
tk:alertin its content.