Alert

Display important messages with different severity levels using ASCII-style icons.

Docs•API Reference
(•)
Information
This is an informational alert with additional details.
(✓)
Success!
Your operation completed successfully.
(→)
Warning
Please review the following before continuing.
(✗)
Error
Something went wrong. Please try again.
(•)
Simple alert without a title.

Installation

npm install react-ascii-ui

Usage

import { AsciiAlert } from 'react-ascii-ui';

export default function Example() {
  return (
    <AsciiAlert variant="info" title="Information">
      This is an informational alert message.
    </AsciiAlert>
  );
}

Examples

Variants

(•)
Info alert
(✓)
Success alert
(→)
Warning alert
(✗)
Error alert
<AsciiAlert variant="info">Info alert</AsciiAlert>
<AsciiAlert variant="success">Success alert</AsciiAlert>
<AsciiAlert variant="warning">Warning alert</AsciiAlert>
<AsciiAlert variant="error">Error alert</AsciiAlert>

With Title

(→)
Important Notice
Please read the documentation before proceeding with the installation.
<AsciiAlert variant="warning" title="Important Notice">
  Please read the documentation before proceeding.
</AsciiAlert>

Complex Content

(✗)
Validation Error

Please fix the following issues:

  • Email is required
  • Password must be at least 8 characters
  • Terms and conditions must be accepted
<AsciiAlert variant="error" title="Validation Error">
  <div>
    <p>Please fix the following issues:</p>
    <ul>
      <li>Email is required</li>
      <li>Password must be at least 8 characters</li>
    </ul>
  </div>
</AsciiAlert>

API Reference

Props

PropTypeDefaultDescription
variant'info' | 'success' | 'warning' | 'error''info'The visual style and icon of the alert
titlestring-Optional title displayed in bold above content
childrenReact.ReactNode-The main content of the alert
classNamestring""Additional CSS classes

Variant Icons

  • info: (i) - Blue color scheme
  • success: (✓) - Green color scheme
  • warning: (âš ) - Yellow color scheme
  • error: (!) - Red color scheme

AsciiAlert extends all HTML div attributes and React.HTMLAttributes.