Skip to content

Search documentation

Search guides, examples, and component APIs.

Quick links
↑↓ NavigateEnter OpenEsc Close
Get started

Documentation navigation

Components / Display

Alert

A static notice surface with composable title, description, action, and icon regions.

Last changed in version 0.13.0: Add avatar groups and chips, expand the block gallery, and improve component colors, spacing, and motion.

Interactive showcase

default

This is the default alert variant.

info

This is the info alert variant.

success

This is the success alert variant.

warning

This is the warning alert variant.

destructive

This is the destructive alert variant.

Install

Run in your project
bunx --bun @getweini/cli@latest add alert

Start with this example

Import the files copied by the install command, then place the component in your Vue template. The text and values in the example belong to your app; change them to fit your task.

Payment method expiring

Update the card before the next invoice.
Vue
<script setup lang="ts">
import Alert from './components/ui/alert/Alert.vue'
import AlertAction from './components/ui/alert/AlertAction.vue'
import AlertDescription from './components/ui/alert/AlertDescription.vue'
import AlertTitle from './components/ui/alert/AlertTitle.vue'
import Button from './components/ui/button/Button.vue'
</script>

<template>
  <Alert variant="warning">
    <AlertTitle>Payment method expiring</AlertTitle>
    <AlertDescription>Update the card before the next invoice.</AlertDescription>
    <AlertAction><Button variant="outline">Update card</Button></AlertAction>
  </Alert>
</template>

No live-region role is added by default. Use alert only for urgent content inserted dynamically, status for polite updates, and neither for ordinary static page content.

When to use it

Form outcome

Confirm that a save finished or explain what prevented submission.

Persistent notice

Keep an important policy or deadline visible with a relevant action.

More examples

Saved confirmation

A polite status works for an update inserted after an action.

Saved confirmation
<script setup lang="ts">
import Alert from './components/ui/alert/Alert.vue'
import AlertDescription from './components/ui/alert/AlertDescription.vue'
import AlertTitle from './components/ui/alert/AlertTitle.vue'
</script>

<template>
  <Alert role="status" variant="success">
    <AlertTitle>Changes saved</AlertTitle>
    <AlertDescription>Your preferences are ready on every device.</AlertDescription>
  </Alert>
</template>

Static deadline

A notice already present at page load does not need a live-region role.

Static deadline
<script setup lang="ts">
import Alert from './components/ui/alert/Alert.vue'
import AlertAction from './components/ui/alert/AlertAction.vue'
import AlertDescription from './components/ui/alert/AlertDescription.vue'
import AlertTitle from './components/ui/alert/AlertTitle.vue'
import Link from './components/ui/link/Link.vue'
</script>

<template>
  <Alert variant="warning">
    <AlertTitle>Review your billing address</AlertTitle>
    <AlertDescription>The next invoice is due on 30 September.</AlertDescription>
    <AlertAction><Link href="/billing">Open billing</Link></AlertAction>
  </Alert>
</template>

Complete API

Every public prop, model, event, slot, and exposed member of the installed Vue parts is listed below. “Not set” means you can leave that value out; “Required” means you must provide it. Native HTML attributes also work where the component uses a native element.

Alert

Complete API for Alert
NameType or signatureDefaultWhat it does
variantprop"default" | "info" | "success" | "warning" | "destructive" | undefined"default"Choose the visual treatment for this component.
roleprop"alert" | "status" | undefinedNot setSet the semantic role announced to assistive technology.
defaultslot() => unknownRequiredContent shown inside Alert.
iconslot(() => unknown) | undefinedOptionalContent for the icon area of Alert.

AlertAction

Complete API for AlertAction
NameType or signatureDefaultWhat it does
defaultslot() => unknownRequiredContent shown inside AlertAction.

AlertDescription

Complete API for AlertDescription
NameType or signatureDefaultWhat it does
defaultslot() => unknownRequiredContent shown inside AlertDescription.

AlertTitle

Complete API for AlertTitle
NameType or signatureDefaultWhat it does
asprop"h2" | "h3" | "h4" | "h5" | "h6" | undefined"h3"Choose the HTML element or Vue component used for this control.
defaultslot() => unknownRequiredContent shown inside AlertTitle.
Public type definitions
Public types
// packages/frameworks/vue/components/alert/types.ts
import type { alertVariants } from './styles'

// ------- TYPES -------

export interface AlertProps {
  variant?: keyof typeof alertVariants
  role?: 'alert' | 'status'
}

export interface AlertTitleProps {
  as?: 'h2' | 'h3' | 'h4' | 'h5' | 'h6'
}


// packages/frameworks/vue/components/alert/styles.ts
// Add or change an Alert color here; the public variant type follows these keys.
export const alertVariants = {
  default: 'border-border bg-card text-card-foreground',
  info: 'border-info-subtle-border bg-info-subtle text-info-subtle-foreground',
  success: 'border-success-subtle-border bg-success-subtle text-success-subtle-foreground',
  warning: 'border-warning-subtle-border bg-warning-subtle text-warning-subtle-foreground',
  destructive:
    'border-destructive-subtle-border bg-destructive-subtle text-destructive-subtle-foreground',
} as const

Implementation notes

  • Content in the icon slot is decorative and hidden from assistive technology.
  • Use status for routine changes and alert only for urgent dynamically inserted messages.
  • Give the action a specific label that describes where it goes or what it does.

Accessibility and localization

  • An alert role on static initial content may interrupt screen-reader navigation unnecessarily.

Source contract and editing guidance