1. Types
default (when type is left out), success, info, warning
and danger. title is the first line, in bold; the slot is the text under it.
icon replaces the type's icon (Font Awesome classes), :icon="false" leaves it out.
This is a test site!
Booking initiated successfully!
19 minutes and 38 seconds
Your search is about to expire!
Your search has expired!
<x-tools.tvt-alert type="warning" title="Your search is about to expire!">
You have 2 minutes left to complete your reservation, after which you must redo your search!
</x-tools.tvt-alert>
<x-tools.tvt-alert type="info" icon="fa-regular fa-plane" :title="$title">{{ $text }}</x-tools.tvt-alert>
2. Compact
size="sm": one line, small text and icon, the title in bold before the text and the actions at the end
of the line. For short messages in a card, a form or an aside. It wraps on a narrow screen.
<x-tools.tvt-alert type="info" size="sm">Children under 2 travel free.</x-tools.tvt-alert>
<x-tools.tvt-alert type="warning" size="sm" title="Price changed:" :dismissible="true">
the flight now costs 642 EUR.
<x-slot:actions>
<a href="...">See why</a>
</x-slot:actions>
</x-tools.tvt-alert>
3. Actions
The actions slot holds the buttons or links that answer the message: under the text, or at the end of
the line with size="sm". Their look is the page's: the alert only lays them out.
Booking initiated successfully!
Your search has expired!
<x-tools.tvt-alert type="danger" title="Your search has expired!">
The search expires after 20 minutes. Please go to the booking engine to make a new search.
<x-slot:actions>
<a href="..." class="...">New search</a>
<a href="..." class="...">Back to results</a>
</x-slot:actions>
</x-tools.tvt-alert>
4. Close, and keep closed
:dismissible="true" adds a close button (close-label is its aria-label). The alert
fades and folds up, so what is under it moves up smoothly, then is removed; the keyboard focus goes to what follows it.
Any [data-tvt-dismiss="alert"] inside an alert closes it, e.g. an "OK" among its actions.
remember="<id>" (dismissible by itself) keeps it closed for the rest of the session, on every page
with an alert of that id: the test-site notice is closed once, not on each page. It is removed on load, before the
page shows. tvtForgetAlert(id) brings it back from the next load.
This is a test site!
New: pay in 3 instalments
Close an alert.
<x-tools.tvt-alert title="This is a test site!" remember="test-site">
The prices are not real and reservations made here are not valid.
</x-tools.tvt-alert>
tvtDismissAlert(alert); // as its close button
tvtForgetAlert('test-site'); // shows again from the next load
document.addEventListener('tvt:alert-dismiss', (e) => console.log(e.target, e.detail.remember));
5. Countdown
<x-tools.tvt-alert-countdown> holds one alert per state and shows the one that matches the time left:
state="running", "warning" from warning-at seconds (120 by default, in
config/alerts.php; without a warning alert the running one stays) and "expired" at zero.
The time is seconds from the page load or until, the end sent by the backend (the expiry of the search).
:time in a title or a text is the time left, every second. time-style: long
(19 minutes, 38 seconds) and short (19 min, 38 sec), in the page's language by the browser, or
digital (19:38), which is also what shows before the JS and in a browser without Intl.DurationFormat.
The alert of the current state is rendered visible, so nothing moves on load.
A screen reader is told when the state changes (politely for the warning, at once for the expiry), not every second.
The countdown fires tvt:alert-state and, at zero, tvt:alert-expire: below, the booking button
is disabled when the search expires. This one starts at 2:15 with the warning from 2:00; the buttons restart it.
2:15
Your search is about to expire!
Your search has expired!
<x-tools.tvt-alert-countdown :until="$searchExpiresAt" :warning-at="120">
<x-tools.tvt-alert state="running" type="info" title=":time">
Time remaining for booking, including completing the payment.
</x-tools.tvt-alert>
<x-tools.tvt-alert state="warning" type="warning" title="Your search is about to expire!">
You have :time left to complete your reservation.
</x-tools.tvt-alert>
<x-tools.tvt-alert state="expired" type="danger" title="Your search has expired!">
Please go to the booking engine to make a new search.
<x-slot:actions><a href="...">New search</a></x-slot:actions>
</x-tools.tvt-alert>
</x-tools.tvt-alert-countdown>
countdown.addEventListener('tvt:alert-expire', () => bookButton.disabled = true);
countdown.addEventListener('tvt:alert-state', (e) => console.log(e.detail)); // { state, remaining, initial }
// starts it again: 20 minutes from now, or until a date
tvtStartAlertCountdown(countdown, 1200);
tvtStartAlertCountdown(countdown, '2026-11-06T18:20:00+02:00');
6. Classes and attributes
Every other attribute goes on the box, and class is added to its own (mb-4, or mb-2
when compact; padding, border, shadow): a width, an id for a script.
A static alert, in the page from the start, needs no role. One that a script adds after load does: role="status"
(read when the reader is free) or role="alert" (read at once, for an error). The countdown needs none: it
announces its changes itself.
<x-tools.tvt-alert type="danger" role="alert" class="max-w-xl" id="payment-error" title="The payment failed.">
Your card was not charged. Please try again or use another card.
</x-tools.tvt-alert>
Props, attributes, events, functions
<x-tools.tvt-alert>
type:default,success,info,warning,danger(config/alerts.php)title; the slot: the text; slotactionssize:md(default) orsmicon: Font Awesome classes,falsefor nonedismissible,remember="<id>",close-labelstate:running,warning,expired, in a countdown- no dark mode yet: it waits for the colour schemes
<x-tools.tvt-alert-countdown>
secondsfrom the load, oruntil(any date PHP parses)warning-at: seconds, defaultcountdown.warning_at(120)time-style:long,short,digital; defaultcountdown.time_style:timein an alert's title or text
Events, functions
tvt:alert-dismiss{ remember }, on the alerttvt:alert-state{ state, remaining, initial },tvt:alert-expire{ initial }, on the countdowntvtDismissAlert(alert),tvtForgetAlert(id)tvtStartAlertCountdown(countdown, secondsOrDate)tvtInitAlerts(root): markup added after load