Feedback
Alert
A message box inside the page flow: a status, a warning or an error, with an optional title, actions, close button and auto-dismiss timer. Use it for messages that belong to a place on the page; for a floating message that is not tied to the layout use tk:toast.
tk:alert renders its own close button with closable; tk:alert.close is only written to place one by hand. tk:alert.session renders the alerts flashed to the session.
Nothing to show
A green box with a check icon, the title and the message. Without closable or duration, it stays on the page.
Closable, with a timer #
The alert collapses after 8 seconds, or when the close button is clicked. A bar at the bottom edge shrinks as the time runs out, and the countdown stops while the pointer or the focus is on the alert.
Nothing to show
Content and actions #
The default slot is the body, under the title. actions sits at the end of the row, before the close button when there is one.
Your trial ends in 3 days
Nothing to show
A list of messages #
An array in message renders as a list, one item per entry.
Nothing to show
Flashing from PHP #
alert() stores the alert in the session under status, and tk:alert.session renders it on the next page. It is available as $this->alert() in a Livewire component, as the alert() helper and as TALLKit::alert(). Called with no arguments it returns a proxy with one method per type (alert()->danger('...')); called with arguments it takes message, type, variant, icon, border, title, closable, duration, size, name, progress and pauseOnHover. Several calls in the same request stack, and each one renders as its own alert. tk:form already includes a tk:alert.session.
Nothing to show
Types #
type sets the color, the default icon and how the alert is announced: info, success, warning or danger.
New feature
Payment received
Low stock
Sync failed
Nothing to show
Variants and borders #
variant is soft (default), outline or subtle. border draws a border all around, or a thick one on one side (top, left, right, bottom).
Nothing to show
Sizes #
size sets padding, font size and icon size, from xs to 3xl.
Size xs
Size sm
Size md
Size lg
Nothing to show
Icons #
icon takes any icon name, or false to hide it.
Welcome aboard
Nothing to show
Progress as a fill #
progress without an edge fills the alert's background as the time runs out.
Nothing to show
Events #
before-dismiss can cancel the close and dismissed fires when the animation ends; both carry the reason. Any element with data-tallkit-dismissible closes the alert.
Nothing to show
Customization #
Classes go to the box; prefixed attributes (icon:, title:, message:, close:) reach the inner elements. title:level turns the title into a heading.
Heads up
Nothing to show
Reference
tk:alert
└── tk:alert.close
tk:alert.session
tk:alert
| Prop | Type | Default | Description |
|---|---|---|---|
type |
string | neutral | info, success, warning or danger (error is an alias). Sets the color, the default icon and how the alert is announced. |
variant |
string | soft |
soft fills the box with the type color, outline keeps it transparent with a colored border, subtle uses a neutral background with a colored icon. |
title |
string | slot | null |
The heading above the message. |
message |
string | array | slot | null |
The text. An array renders as a list. |
icon |
string | bool | by type | An icon name, or false for no icon. |
border |
bool | string | false, true with outline |
true draws a border all around; top, left, right or bottom draws a thick one on that side and squares the corners. |
closable |
bool | string | false |
Adds a close button. A string is the icon name for it. |
duration |
int | string | bool | off | Closes the alert after this time: milliseconds (5000), or a string with a unit (5s, 500ms). true picks a time from the length of the text, between 3 and 9 seconds. |
progress |
bool | string | false |
Shows the remaining time: true as a fill behind the content, top or bottom as a bar on that edge. Without duration it turns the timer on, as duration true. |
pauseOnHover |
bool | true |
Stops the timer while the pointer is over the alert. |
size |
string | md |
xs, sm, md, lg, xl, 2xl or 3xl. Sets padding, font size and icon size. |
prepend |
slot | null |
Content before the title. |
append |
slot | null |
Content after the message. |
actions |
slot | null |
Controls at the end of the row. |
Slots
| Slot | Description |
|---|---|
| default | The body, under the title and the message. |
title |
The heading, in place of the title prop. |
message |
The text, in place of the message prop. |
prepend |
Content before the title. |
append |
Content after the message. |
actions |
Controls at the end of the row, before the close button. |
Events
| Event | Detail | When |
|---|---|---|
before-dismiss |
{ reason } |
The alert is about to close. Cancelable: preventDefault() keeps it open. |
dismissed |
{ reason } |
The closing animation finished. |
restored |
A Livewire update brought back a closed alert with new content. |
Prefixes
| Prefix | Goes to |
|---|---|
icon: |
The icon. icon:class is added to its own classes, and wins over the type color. |
container: |
The element wrapping title, message and body. |
title: |
The heading. It is a <p>; title:level="2" makes it an <h2>. |
message: |
The message text and the body. |
list: |
The list, when message is an array. |
actions: |
The element wrapping the actions and the close button. |
close: |
The close button. |
progress: |
The progress track; progress:bar:class reaches the bar. |
tk:alert.session
| Prop | Type | Default | Description |
|---|---|---|---|
name |
string | status |
The session key to read. |
title |
string | slot | null |
A title for every alert it renders. |
prepend |
slot | null |
Passed to every alert. |
append |
slot | null |
Passed to every alert. |
actions |
slot | null |
Passed to every alert. |
Every other attribute is passed to each alert (closable, variant, class...), and overrides the same key in the flashed value. The value in the session can be a string (the message), an array of tk:alert props, or a list of either.
Slots
| Slot | Description |
|---|---|
| default | The body of every alert it renders. |
tk:alert.close
| Prop | Type | Default | Description |
|---|---|---|---|
icon |
string | mdi:close |
The button icon. |
size |
string | md |
Sets the icon size. |
Also accepts the element props (label, suffix, kbd...).
Slots
| Slot | Description |
|---|---|
| default | The button content, in place of the icon. |
Prefixes
| Prefix | Goes to |
|---|---|
icon: |
The button icon. |
Events
Events are dispatched on the alert's own element and do not bubble: listen on the tag itself.
reason is manual (close button), timeout (the duration ran out) or programmatic.
The alert also listens to events dispatched on it:
| Event | Detail | Effect |
|---|---|---|
tallkit:dismiss |
{ reason }, optional |
Closes the alert. |
tallkit:pause |
Stops the timer. | |
tallkit:resume |
Starts it again. |
With Alpine:
Nothing to show
Calling a Livewire action:
Nothing to show
Customization
Classes and attributes on a tag go to its root element. To reach an inner element, prefix the attribute (listed in the Reference above).
Nothing to show
Any element inside the alert with the data-tallkit-dismissible attribute closes it on click, which is how a custom button dismisses it:
Nothing to show
Accessibility
The alert is a live region, with aria-atomic="true" so it is read as a whole. danger and warning get role="alert" and aria-live="assertive"; the other types get role="status" and aria-live="polite". Pass role and aria-live to override them, for an alert that is part of the page and not a notification. An alert that appears after the page has loaded, like a status from a Livewire action that stays on the page, is also read through a shared hidden live region of the same politeness, because a live region inserted already filled is often not announced. This does not happen for the alerts of a page reached with wire:navigate, which are page content, nor for an alert that is hidden or nested inside another alert. Each tk:alert.session alert has its own wire:key, so a new status replaces the previous alert instead of reusing it. Your own scripts can use the same region with tallkit.announce(text), or tallkit.announce(text, 'assertive') for something urgent.
The close button is a <button> named "Close" (translated), with a tooltip. The timer stops while the focus is inside the alert, and when the alert closes with the focus inside, the focus moves to the next focusable element on the page. With prefers-reduced-motion the alert closes without the collapse animation.
Behavior notes
- Without a title, the icon and the actions are centered vertically on the text; with a title, they line up with its top.
progressonly shows with a timer: withduration="0"it is ignored.- A number in
durationis milliseconds:duration="5"closes the alert almost at once. Write5sfor seconds. - The timer also stops while the browser tab is hidden. It only runs again when nothing is pausing it: pointer, focus, tab and
tallkit:pauseeach count on their own. - Outside Livewire a closed alert is removed from the page. Inside a Livewire component it is hidden and stays hidden across updates, until an update changes its content: then it shows again, the timer restarts and
restoredfires. - A timer in progress keeps running through a Livewire update.
- In an alert nested inside another, the close button closes only the inner one.
message:attributes do not reach the list of an arraymessage; uselist:.- A flashed alert lasts one request, so a
tk:alert.sessioninside a Livewire component is gone on the next update.