Alert

The Alert component displays important messages to users with different severity levels.

Installation

npm install @duskmoon-dev/el-alert

Usage

import '@duskmoon-dev/el-alert/register';
<el-dm-alert type="info" title="Information">
  This is an informational message.
</el-dm-alert>

Live Demo

Alert Types

This is an info message.Operation completed successfully.Please review before proceeding.An error occurred.

Properties

PropertyTypeDefaultDescription
type'info' | 'success' | 'warning' | 'error''info'Alert severity
variant'filled' | 'outlined'-Visual style variant
dismissiblebooleanfalseShows close button
compactbooleanfalseUses compact styling
titlestring-Alert title

Types

Alert Types

Info alertSuccess alertWarning alertError alert
<el-dm-alert type="info">Info alert</el-dm-alert>
<el-dm-alert type="success">Success alert</el-dm-alert>
<el-dm-alert type="warning">Warning alert</el-dm-alert>
<el-dm-alert type="error">Error alert</el-dm-alert>

Variants

Alert Variants

Filled infoOutlined info
<el-dm-alert type="info" variant="filled">Filled info</el-dm-alert>
<el-dm-alert type="info" variant="outlined">Outlined info</el-dm-alert>

Dismissible

Dismissible Alert

Click the X to dismiss this alert.

<el-dm-alert type="info" dismissible title="Dismissible">
  Click the X to dismiss this alert.
</el-dm-alert>

Events

EventDescription
dismissFired when alert is dismissed

Event Handling

const alert = document.querySelector('el-dm-alert');
alert.addEventListener('dismiss', () => {
  console.log('Alert dismissed');
});

Slots

SlotDescription
defaultAlert content
iconCustom icon
actionsAction buttons

Accessibility

  • Uses role="alert" for screen reader announcements
  • Dismissible alerts have accessible close buttons
  • Color is not the only indicator of severity