Skip to main content

MCDS


Alert

A component for displaying important information to users with optional dismissible functionality.

Code

<Alert type="info">
  This is an informational alert.
</Alert>
<Alert type="success">
  Operation completed successfully!
</Alert>
<Alert type="warning">
  Be cautious with this action.
</Alert>
<Alert type="error">
  An error occurred. Please try again.
</Alert>
<Alert type="info" dismissible={true} id="custom-alert">
  This alert can be dismissed by clicking the X button.
</Alert>

Props

Name Type Required Description
type "info" | "success" | "warning" | "error" No The type of alert that determines its visual appearance and emoji
Default: "info"
dismissible boolean No Whether the alert can be dismissed by the user
Default: false
id string No Unique identifier for the alert. If not provided, a random ID will be generated

Usage

Do’s

  • Use dismissible alerts for messages that are intended to disrupt the user’s flow
  • Use for important status messages and notifications
  • Place alerts at the top of the content area
  • Keep messages clear and concise

Don’t’s

  • Don’t stack too many alerts at once
  • Don’t include complex interactive elements
  • Don’t use for general content or decorative purposes

Accessibility

Keyboard Navigation

Screen Reader Support