Skip to content

Alert

Component for displaying feedback messages

Basic Usage

Supports four types via the type prop: success, warning, danger, and info. Defaults to info.

this is the alert
this is the alert
this is the alert
this is the alert
<template>
    <Alert type="success" closable>this is the alert</Alert>
    <Alert type="warning" closable>this is the alert</Alert>
    <Alert type="info" closable>this is the alert</Alert>
    <Alert type="danger" closable>this is the alert</Alert>
</template>

<script setup lang="ts">
import Alert from '@/components/Alert/Alert.vue'
</script>

Theme Types

this is the alert
this is the alert
this is the alert
this is the alert
<template>
    <Alert type="success" effect="dark" closable>this is the alert</Alert>
    <Alert type="warning" effect="dark" closable>this is the alert</Alert>
    <Alert type="info" effect="dark" closable>this is the alert</Alert>
    <Alert type="danger" effect="dark" closable>this is the alert</Alert>
</template>

<script setup>
import Alert from '@/components/Alert/Alert.vue'
</script>

Closable

without close
<template>
  <Alert type="success" :closable="false">without close</Alert>
</template>

<script setup>
import Alert from '@/components/Alert/Alert.vue'
</script>

Function Mode

Use the createAlert() utility to trigger alerts programmatically.

<template>
  <Button type="success" @click="handleClick">Click me</Button>
</template>
<script setup lang="ts">
import { createAlert } from '@/components/Alert/createAlert'
import Button from '@/components/Button/Button.vue'
const handleClick = () => {
  createAlert({
    type: 'success',
    message: 'Funtional Alert!',
    closable: true,
    duration: 3000
  })
}
</script>

API

Alert Attributes

AttributeDescriptionTypeDefault
typeTheme typesuccess | warning | danger | infoinfo
effectStyle themelight | darklight
closableWhether it is closablebooleanfalse
durationAuto-close delay in ms (0 disables)number3000
messageMessage content (VNode or string)string | VNode

Alert Events

EventDescriptionParameters
closeTrigger on close-

Alert Slots

NameDescription
defaultCustom content