Alert

A short, important message. Kobalte's Alert is one element with role="alert", which the Kobalte layer binds, so it needs no class at all.

alpha The class names and states here are stable. The look is not: these styles can change in a minor release, without a major version bump.

ClassDoes what
alertThe message box
alert-errorRecolours it with --error

Basic

<div class="alert" role="alert">Your changes have been saved.</div>
<div class="alert alert-error" role="alert">We could not reach the server.</div>

There is no info, success or warning variant yet. The framework derives everything from one --primary plus --error, and those variants need tokens it does not have.

Composition

Common ways to put this together with other components. The general rules are on Composition.

At the top of a form

A form-level error goes above the fields, inside the card, so it is read before the fields are.

Same markup in both builds
<form class="card">
  <div class="alert alert-error" role="alert">We could not send your message. Try again in a minute.</div>
  <label class="label">
    <p>Email</p>
    <input class="input" type="email" />
  </label>
  <footer class="card-actions flex" style="justify-content: end">
    <button class="btn">Send</button>
  </footer>
</form>

A toast after a form is sent

The form clears and a toast confirms it, out of the way of the next thing the visitor does.

Same markup in both builds
<form class="card" style="max-width: 24rem">
  <label class="label"><p>Email</p><input class="input" type="email" /></label>
  <button class="btn">Subscribe</button>
</form>
<ul class="toast" style="position: static; max-width: 22rem; margin-top: var(--padding)">
  <li class="alert" role="status">
    <span><span class="toast-title">Subscribed</span><br /><span class="toast-description">Check your inbox to confirm.</span></span>
  </li>
</ul>