Alerts

Contextual feedback messages for typical user actions. Choose from semantic color variants, add dismissible close buttons, or combine icons with text for richer communication. Alerts are fully CSS-driven — no JavaScript required for static use.

Semantic Variants
Primary. A general informational message for the user.
Success. Your changes have been saved successfully.
Warning. Your subscription expires in 3 days.
Danger. Unable to connect to the server. Please try again.
Tip. You can customize alert colors via CSS variables.
<!-- Primary alert -->
<div class="vd-alert vd-alert-primary">
  <i class="ph ph-info"></i>
  <div><strong>Primary.</strong> A general message.</div>
</div>

<!-- Success alert -->
<div class="vd-alert vd-alert-success">
  <i class="ph ph-check-circle"></i>
  <div>Your changes have been saved.</div>
</div>

<!-- Warning alert -->
<div class="vd-alert vd-alert-warning">...</div>

<!-- Danger alert (.vd-alert-error remains as an alias) -->
<div class="vd-alert vd-alert-danger">...</div>

<!-- Info alert -->
<div class="vd-alert vd-alert-info">...</div>
Dismissible & With Actions
Profile updated successfully.
Storage warning. You are using 95% of your quota. Upgrade now
New features available

Dark mode, custom themes, and more are now live. Learn more

<!-- Dismissible alert -->
<div class="vd-alert vd-alert-success vd-alert-dismissible">
  <i class="ph ph-check-circle"></i>
  <div>Profile updated.</div>
  <button class="vd-alert-close" aria-label="Close alert">&times;</button>
</div>

<!-- Alert with link -->
<div class="vd-alert vd-alert-warning">
  <i class="ph ph-warning"></i>
  <div>
    Storage warning. <a href="#" class="vd-alert-link">Upgrade now</a>
  </div>
</div>

<!-- Alert with heading -->
<div class="vd-alert vd-alert-primary">
  <i class="ph ph-info"></i>
  <div>
    <h5 class="vd-alert-heading">New features</h5>
    <p class="vd-mb-0 vd-text-sm">Dark mode and more.</p>
  </div>
</div>
CSS Variables
VariableDefaultDescription
--vd-alert-padding-x1.3125rem (21px)Horizontal padding (Fibonacci)
--vd-alert-padding-y0.8125rem (13px)Vertical padding (Fibonacci, ratio ~phi)
--vd-alert-border-radiusvar(--vd-btn-border-radius)Corner rounding
--vd-alert-border-width1pxBorder thickness
--vd-alert-primary-bgvar(--vd-color-primary-alpha-10)Primary variant background
--vd-alert-success-bgvar(--vd-color-success-alpha-10)Success variant background
--vd-alert-warning-bgvar(--vd-color-warning-alpha-10)Warning variant background
--vd-alert-error-bgvar(--vd-color-error-alpha-10)Error variant background
--vd-alert-info-bgvar(--vd-color-info-alpha-10)Info variant background
API Reference

Usage

<script setup lang="ts">
import { VdAlert } from "@vanduo-oss/vd3";
</script>

<template>
  <VdAlert variant="success" title="Saved">Your changes are saved.</VdAlert>

  <!-- danger replaces the former error spelling -->
  <VdAlert variant="danger" dismissible @dismiss="onDismiss">
    Unable to connect to the server.
  </VdAlert>
</template>

CSS Classes

ClassDescription
.vd-alertBase alert container. Flex layout with icon + content.
.vd-alert-primaryBlue accent variant for general information.
.vd-alert-successGreen accent variant for positive feedback.
.vd-alert-warningAmber accent variant for cautionary messages.
.vd-alert-dangerRed accent variant — the unified status name (matches Vue variant="danger").
.vd-alert-errorRetained backward-compatible alias for .vd-alert-danger.
.vd-alert-infoCyan accent variant for tips and hints.
.vd-alert-dismissibleAdds right padding for a close button.
.vd-alert-closeClose button positioned at top-right.
.vd-alert-linkStyled link inside an alert with matching variant color.
.vd-alert-headingHeading style for titled alerts.
.vd-alert-iconFlex container for the icon (auto-generated structure).

Component API (Vue 3)

Prop / slot / eventDescription
:variantprimary | secondary | success | warning | danger | info (default "info"). Selects the leading icon automatically.
:titleOptional bold title rendered above the slot content.
:dismissibleRenders a close button that emits dismiss.
default slotAlert body content.
@dismissEmitted when the close button is clicked.
Accessibility
  • Use role="alert" on dynamically injected alerts so screen readers announce them immediately.
  • Dismissible alerts should have a button with an aria-label="Close alert", not just an icon.
  • Icons inside alerts should have aria-hidden="true" if they are decorative; otherwise provide text alternatives.
  • Color is never the sole indicator — pair variants with distinct icons and clear text.
  • Alert links (.vd-alert-link) maintain sufficient contrast against all variant backgrounds.