Simple Display Alert

A lightweight, customizable alert system for modern web applications

Interactive Demo

Basic Alerts

Special Alerts

Position Variants

Multiple Alerts

Installation

Install Package

npm i @jaymago/simple-display-alert

Run Example Locally

# Clone the repository
git clone https://github.com/jaymagoit/simple-display-alert.git

# Navigate to example directory
cd simple-display-alert/example

# Install dependencies
npm install

# Start development server
npm run dev

Basic Usage

1. Import the Package and Styles

// Import the package
import { 
    displayAlert,          // Generic alert function
    displayAlertSuccess,   // Success variant
    displayAlertError,     // Error variant
    displayAlertWarning,   // Warning variant
    displayAlertInfo,      // Info variant
    displayAlertLoader     // Loading variant
} from '@jaymago/simple-display-alert';

// Import the CSS (required)
import '@jaymago/simple-display-alert/dist/index.css';

2. Basic Examples

// Success message (green)
displayAlertSuccess('Operation completed successfully!');

// Error message (red)
displayAlertError('An error occurred!');

// Warning message (yellow)
displayAlertWarning('Please check your input');

// Info message (blue)
displayAlertInfo('This is an informational message');

// Loading message (with spinner)
displayAlertLoader('Loading...');

3. Advanced Usage with Options

// Success alert with custom position and animation
displayAlertSuccess('Success with options', { 
    position: 'top-right',     // Position in top-right corner
    fadeDirection: 'left'      // Slide in from right
});

// Error alert that stays visible and allows multiple alerts
displayAlertError('Error with options', { 
    timeout: 0,                // Stays indefinitely
    multiple: true            // Can stack with other alerts
});

Configuration Options

Option Type Default Description
position string 'bottom-right' 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'
fadeDirection string 'none' 'none' | 'left' | 'right' | 'top' | 'bottom'
timeout number 5000 Duration in ms (0 for no auto-hide)
multiple boolean false Allow multiple alerts to stack
variant string 'success' 'success' | 'error' | 'warning' | 'info' | 'white' | 'loader'

Features