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
| Variable | Default | Description |
|---|---|---|
--vd-alert-padding-x | 1.3125rem (21px) | Horizontal padding (Fibonacci) |
--vd-alert-padding-y | 0.8125rem (13px) | Vertical padding (Fibonacci, ratio ~phi) |
--vd-alert-border-radius | var(--vd-btn-border-radius) | Corner rounding |
--vd-alert-border-width | 1px | Border thickness |
--vd-alert-primary-bg | var(--vd-color-primary-alpha-10) | Primary variant background |
--vd-alert-success-bg | var(--vd-color-success-alpha-10) | Success variant background |
--vd-alert-warning-bg | var(--vd-color-warning-alpha-10) | Warning variant background |
--vd-alert-error-bg | var(--vd-color-error-alpha-10) | Error variant background |
--vd-alert-info-bg | var(--vd-color-info-alpha-10) | Info variant background |
API Reference
VdAlert Component
Saved
Your changes are saved via
<VdAlert>. Unable to connect to the server.
<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
| Class | Description |
|---|---|
.vd-alert | Base alert container. Flex layout with icon + content. |
.vd-alert-primary | Blue accent variant for general information. |
.vd-alert-success | Green accent variant for positive feedback. |
.vd-alert-warning | Amber accent variant for cautionary messages. |
.vd-alert-danger | Red accent variant — the unified status name (matches Vue variant="danger"). |
.vd-alert-error | Retained backward-compatible alias for .vd-alert-danger. |
.vd-alert-info | Cyan accent variant for tips and hints. |
.vd-alert-dismissible | Adds right padding for a close button. |
.vd-alert-close | Close button positioned at top-right. |
.vd-alert-link | Styled link inside an alert with matching variant color. |
.vd-alert-title | Heading style for titled alerts. |
.vd-alert-icon | Flex container for the icon (auto-generated structure). |
Component API (Vue 3)
| Prop / slot / event | Description |
|---|---|
:variant | primary | secondary | success | warning | danger | info (default "info"). Selects the leading icon automatically. |
:title | Optional bold title rendered above the slot content. |
:dismissible | Renders a close button that emits dismiss. |
:animated | Enable smooth WAAPI collapse animation on dismiss. Default true. |
default slot | Alert body content. |
@dismiss | Emitted 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
buttonwith anaria-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.