Skip to content
loseta

Components / Surfaces

Alert

Displays a callout for user attention.

Status stableWorks with button
<div class="alert" role="alert">
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21.801 10A10 10 0 1 1 17 3.335"/><path d="m9 11 3 3L22 4"/></svg>
  <h3 data-slot="title">Heads up!</h3>
  <section>
    <p>You can add components and dependencies to your app using the CLI.</p>
  </section>
</div>

Installation

pnpm dlx loseta add alert
npx loseta add alert

Examples

Destructive

<div class="alert" data-variant="destructive" role="alert">
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><line x1="12" x2="12" y1="8" y2="12"/><line x1="12" x2="12.01" y1="16" y2="16"/></svg>
  <h3 data-slot="title">Payment failed</h3>
  <section>
    <p>Your payment could not be processed. Please check your payment method and try again.</p>
  </section>
</div>

Action

<div class="alert" role="alert">
  <h3 data-slot="title">Dark mode is now available</h3>
  <p data-slot="description">Enable it under your profile settings to get started.</p>
  <footer>
    <button type="button" class="btn" data-size="xs">Enable</button>
  </footer>
</div>

Description container

<div class="alert" role="alert">
  <h3 data-slot="title">Using the CLI</h3>
  <div data-slot="description">
    <p>Add components and dependencies with the CLI.</p>
    <p>Then customize the alert with your own tokens.</p>
  </div>
</div>

Custom colors

<div class="alert" role="alert" style="--card: color-mix(in oklab, var(--chart-4) 10%, var(--background)); --border: color-mix(in oklab, var(--chart-4) 40%, var(--background)); --muted-foreground: color-mix(in oklab, var(--chart-4) 35%, var(--foreground))">
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/><path d="M12 9v4"/><path d="M12 17h.01"/></svg>
  <h3 data-slot="title">Your subscription will expire in 3 days.</h3>
  <section>
    <p>Renew now to avoid service interruption or upgrade to a paid plan to continue using the service.</p>
  </section>
</div>

Right-to-left

<div dir="rtl" lang="ar" style="display: grid; gap: 1rem">
  <div class="alert" role="alert">
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21.801 10A10 10 0 1 1 17 3.335"/><path d="m9 11 3 3L22 4"/></svg>
    <h3 data-slot="title">تم الدفع بنجاح</h3>
    <section>
      <p>تمت معالجة دفعتك البالغة 29.99 دولارًا. تم إرسال إيصال إلى عنوان بريدك الإلكتروني.</p>
    </section>
  </div>
  <div class="alert" role="alert">
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg>
    <h3 data-slot="title">ميزة جديدة متاحة</h3>
    <section>
      <p>لقد أضفنا دعم الوضع الداكن. يمكنك تفعيله في إعدادات حسابك.</p>
    </section>
  </div>
</div>

Accessibility and behavior

  • Add role="alert" for messages that appear after load. Mark a decorative direct SVG icon aria-hidden="true". The title accepts h2–h6, strong or [data-slot="title"]; the description is a section or [data-slot="description"], and footer holds the action. Custom colors come from overriding --card, --border and --muted-foreground.

Files

components/alert.cssbase
styles/nova/alert.cssstyle

Install contract

The CLI writes the base file under components/, the visual file for the selected style under styles/<name>/, and any primitive dependency underprimitives/. The generated index.css imports them in the right layer order.

← Back to components

loseta is MIT licensed. Built with native CSS, no runtime. Inspired byshadcn/ui.