Alert

A versatile alert component for displaying important messages and contextual information with support for different severity levels and custom icons.

Usage

Basic Alert

The Alert component displays important information with a default circle-exclamation icon and the PPG variant.

import { Alert } from "@prisma/eclipse";

export function BasicAlert() {
  return (
    <Alert>
      This is a basic alert message with regular content.
    </Alert>
  );
}

Live Example:

Alert Variants

The Alert component supports four variants: ppg, error, success, and warning.

import { Alert } from "@prisma/eclipse";

export function AlertVariants() {
  return (
    <>
      <Alert variant="ppg">
        PPG variant - for general information and tips.
      </Alert>

      <Alert variant="success">
        Success variant - for positive confirmations.
      </Alert>

      <Alert variant="warning">
        Warning variant - for important notices.
      </Alert>

      <Alert variant="error">
        Error variant - for errors and critical information.
      </Alert>
    </>
  );
}

Live Examples:

Custom Icons

You can customize the icon by passing a custom icon component or pass null to hide the icon.

import { Alert } from "@prisma/eclipse";

export function CustomIconAlerts() {
  return (
    <>
      <Alert variant="ppg" icon={<i className="fa-regular fa-terminal h-4 w-4 mt-0.5" />}>
        Alert with a custom terminal icon.
      </Alert>

      <Alert variant="error" icon={<i className="fa-regular fa-circle-exclamation h-4 w-4 mt-0.5" />}>
        Alert with a custom error icon.
      </Alert>

      <Alert variant="success" icon={<i className="fa-regular fa-check h-4 w-4 mt-0.5" />}>
        Alert with a custom success icon.
      </Alert>

      <Alert variant="warning" icon={<i className="fa-regular fa-triangle-exclamation h-4 w-4 mt-0.5" />}>
        Alert with a custom warning icon.
      </Alert>

      <Alert variant="ppg" icon={null}>
        Alert without an icon.
      </Alert>
    </>
  );
}

Live Examples:

Rich MDX Content

The Alert component accepts and renders any MDX content including headings, paragraphs, lists, links, and code.

import { Alert } from "@prisma/eclipse";

export function RichContentAlert() {
  return (
    <Alert variant="ppg">
      **Getting Started**

      Follow these steps to get started:

      1. Install the package: `npm install @prisma/client`
      2. Initialize Prisma: `npx prisma init`
      3. Define your schema and run migrations

      For more information, visit the [documentation](https://prisma.io/docs).
    </Alert>
  );
}

Getting Started

Follow these steps to get started:

  1. Install the package: npm install @prisma/client
  2. Initialize Prisma: npx prisma init
  3. Define your schema and run migrations

For more information, visit the documentation.

Complex Content Examples

import { Alert } from "@prisma/eclipse";

export function ComplexAlerts() {
  return (
    <>
      <Alert variant="warning">
        ### Important Update

        This feature will be deprecated in version 6.0. Please migrate to the new API:

        - Old: `prisma.user.findMany()`
        - New: `prisma.user.findMany({ where: {} })`
      </Alert>

      <Alert variant="error">
        **Connection Error**

        Unable to connect to the database. Please check:

        - Database credentials in `.env`
        - Database server is running
        - Network connectivity
      </Alert>

      <Alert variant="success">
        Your migration was successful! The following changes were applied:

        - Created table `User`
        - Added index on `email` column
        - Updated foreign key constraints
      </Alert>
    </>
  );
}

Live Examples:

Alert Props

  • variant - Visual style: "ppg", "error", "success", or "warning" (optional, default: "ppg")
  • icon - Custom icon component or null to hide icon (ReactNode | null, optional, default: circle-exclamation icon)
  • className - Additional CSS classes (optional)
  • children - Alert content (any valid MDX/React content) (ReactNode, required)
  • Standard HTML div attributes

Features

  • ✅ Four semantic variants: ppg, error, success, warning
  • ✅ Default circle-exclamation icon with customization support
  • ✅ Accepts any MDX content (headings, paragraphs, lists, code, etc.)
  • ✅ Supports rich formatting and links
  • ✅ Accessible with proper ARIA roles
  • ✅ Dark mode support for all variants
  • ✅ Fully customizable with className prop
  • ✅ Built with class-variance-authority for type-safe variants

Best Practices

  • Use variant="ppg" for general information, tips, and product-specific notes
  • Use variant="success" for positive confirmations and successful operations
  • Use variant="warning" for important notices that require attention
  • Use variant="error" for errors, failures, and critical information
  • Choose icons that match the message type and variant
  • Pass icon={null} if the message is self-explanatory without an icon
  • Use headings (##, ###) to structure complex alert content
  • Include actionable information or next steps when appropriate
  • Keep alerts concise but informative
  • Don't overuse alerts - reserve them for important information

Common Use Cases

The Alert component is perfect for:

  • Documentation callouts - Highlight important information in docs
  • Feature announcements - Announce new or beta features
  • Deprecation notices - Warn about deprecated features
  • Prerequisites - List requirements before proceeding
  • Success confirmations - Confirm successful actions or operations
  • Error messages - Display error details and troubleshooting steps
  • Warning messages - Alert users to important considerations
  • Tips and notes - Provide helpful tips and additional context

MDX Alert Syntax

This Alert component is automatically used for MDX alert blocks when configured in your MDX components. The following syntaxes are supported:

:::ppg
This is a PPG alert using MDX alert syntax.

## You can use any MDX content

Including lists, code, and more!
:::

:::error
This is an error alert.
:::

:::success
This is a success alert.
:::

:::warning
This is a warning alert.
:::

:::info
Maps to PPG variant.
:::

:::note
Maps to PPG variant.
:::

:::tip
Maps to success variant.
:::

:::danger
Maps to error variant.
:::

Live Example:

This demonstrates how the :::ppg syntax renders as an Alert component.

You can include:

  • Lists
  • Bold text
  • inline code
  • And more!

Accessibility

  • The Alert component includes role="alert" for screen readers
  • Icons are decorative and don't convey meaning alone - always include descriptive text
  • Color is not the only indicator of alert type (icons and context provide additional cues)
  • All variants maintain appropriate color contrast ratios
  • Alert content is keyboard accessible and screen reader friendly

On this page