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.
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

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

VdAlert Component

<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-titleHeading 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.
:animatedEnable smooth WAAPI collapse animation on dismiss. Default true.
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.