Alert

Displays a description for the user's attention.

This is an info alert
This is an success alert
This is an warning alert
This is an error alert

Installation

If @melio-ui/react is already installed globally, you can skip this step.

Import

  • AlertRoot: All parts of the alert are included.
  • AlertStatusIcon: Alert icon changes depending on status.
  • AlertContent: The content of the alert to be announced by screen readers.

Another way to import

'use client';
import { Alert } from '@melio-ui/alert';
<Alert.Root>
<Alert.StatusIcon />
<Alert.Content>Content1</Alert.Content>
</Alert.Root>;

'use client' must be used when rendering on the server side.

API Reference

AlertRoot

All parts of the alert are included.

PropTypeDefaultDescription
statusTypeAttributes.Status

"info" | "success" | "warning" | "error"
"info"The status of the alert.
Data attributeValues
[data-status]"info" | "success" | "warning" | "error"

AlertStatusIcon

Alert icon changes depending on status.

PropTypeDefaultDescription
infoReact.ReactNode<InfoIcon />displaying an icon for info status.
successReact.ReactNode<SuccessIcon />displaying an icon for success status.
warningReact.ReactNode<WarningIcon />displaying an icon for warning status.
errorReact.ReactNode<ErrorIcon />displaying an icon for error status.

AlertContent

The content of the alert to be announced by screen readers.

Data attributeValues
[data-status]"info" | "success" | "warning" | "error"

Examples

Set the status value

<Alert.Root status="success">
<Alert.StatusIcon />
<Alert.Content>This is an success alert</Alert.Content>
</Alert.Root>

Custom

<Alert.Root>
<Alert.StatusIcon />
<Alert.Content>
<div style={{ marginTop: -2, fontWeight: 'bold', marginBottom: '0.35em' }}>information</div>
<div>This is an info alert</div>
</Alert.Content>
</Alert.Root>
DocsMelioUI
Copyright © Ahn Co. All rights reserved.