Alerts are used to capture the attention of the user in an intrusive way.

installyarn add @clayui/alert
versionNPM Version
useimport Alert from '@clayui/alert';
Don’t forget to check WAI-ARIA accessibility pratices for alerts when writting your markup.

Colors

Lexicon adopts in its design system the following colors below:

.alert.alert-success
.alert.alert-info
.alert.alert-warning
.alert.alert-danger

Non-standard Colors

The colors below do not follow Lexicon standards but follow the idea of ​​satellite components, Clay provides non-standard colors to give you more flexibility to build UI that belong to the product.

.alert.alert-primary
.alert.alert-secondary
.alert.alert-dark
.alert.alert-light

Variant Sass API

The map $alert-palette allows generating any number of alert variants. If a key starts with ., # or %, Clay will output it as is, otherwise we will prepend .alert- to the key (e.g., .alert-primary). It will also generate a Sass placeholder prefixed by %calert- (e.g., %alert-primary).

Snippet

Outputs:

Snippet

Examples

Toast

This type of alert is specific for toast messages. These type of messages appear on the top right corner of the screen. The maximum width of a toast message is 360px, and the height can vary depending on the number of rows. It always has a close action.

Error: This is an error message
Info: This is an info message.
Success: This is a success message
Warning: This is a warning message.

Snippet

Embedded

Embedded alerts are meant for use in forms. Usually you will only need to use the information once. Its width depends on the width of the container it is placed in, always respecting the container margins to the content. The close action is not required for embedded alerts.

Error: This is an error message
Error: This is a success message
Error: This is an info message
Error: This is a warning message

Snippet

Stripe

Stripe alerts are always placed below the last navigation element, either the header or the navigation bar. This alert usually appears on “Save” action, communicating the status of the action once received from the server. The close action is mandatory in this alert type. Its width is always full container width and pushes all the content below it.

Danger This is an error message
Success This is a success message
Info This is an info message
Warning This is a warning message

Snippet

Feedback

Add the modifier alert-feedback on the alert element to remove the background, border, and padding.

Primary Indicator:with some additional text and a link.
Autofit Primary Indicator
Secondary Indicator:with some additional text and a link.
Secondary Indicator
Success Indicator:with some additional text and a link.
Success Indicator
Info Indicator:with some additional text and a link.
Info Indicator
Warning Indicator:with some additional text and a link.
Warning Indicator
Danger Indicator:with some additional text and a link.
Danger Indicator

Snippet

Indicator Start

An alternative to using autofit utilities, this keeps the text after the indicator icon from flowing under the icon when it breaks to a new line.

alert-dismissible

Success:Strong kopi-luwak half and half single origin single shot, half and half instant latte brewed latte. At, decaffeinated, blue mountain viennese barista, spoon carajillo shop viennese dark. And ristretto caffeine, plunger pot black, café au lait galão flavour foam strong. Macchiato roast, breve fair trade seasonal et cultivar.

alert-fluid

Primary:Strong kopi-luwak half and half single origin single shot, half and half instant latte brewed latte. At, decaffeinated, blue mountain viennese barista, spoon carajillo shop viennese dark. And ristretto caffeine, plunger pot black, café au lait galão flavour foam strong. Macchiato roast, breve fair trade seasonal et cultivar.

alert-feedback

Danger:Strong kopi-luwak half and half single origin single shot, half and half instant latte brewed latte. At, decaffeinated, blue mountain viennese barista, spoon carajillo shop viennese dark. And ristretto caffeine, plunger pot black, café au lait galão flavour foam strong. Macchiato roast, breve fair trade seasonal et cultivar.

Snippet

Inline

This changes an alert to use display: inline-block. It will only expand to be as wide as its content and max out at the parent container’s width.

Success:File uploaded. Would you like to add categories automatically?

Alert:A file with this name already exists.

Info:Would you like to add categories automatically?

Info:Would you like to add categories automatically?
Error:The file wasn’t uploaded.

Snippet

Autofit Stacked

The class alert-autofit-stacked forces each autofit-col to stack on top of each other, apply it on the alert element.

Success:File uploaded. Would you like to add categories automatically?

Snippet

Autofit Stacked Sm Down

The class alert-autofit-stacked-sm-down forces each autofit-col to stack on top of each other at screen sizes 767px and below, apply it on the alert element.

Success:File uploaded. Would you like to add categories automatically?

Snippet

Autofit Stacked Xs Down

The class alert-autofit-stacked-xs-down forces each autofit-col to stack on top of each other at screen sizes 575px and below, apply it on the alert element.

Success:File uploaded. Would you like to add categories automatically?

Snippet

Non-standard Examples

These examples are not included in the Lexicon design system but they are built using foundations and Lexicon core components, these components may belong to the product or application.

Alert Lists

  • 1 Files couldn’t upload.
  • RTF

    file-upload.RTF

    Error: couldn’t upload.
  • JPG

    file-name.JPG

    Uploaded - 142.1KB
  • RTF

    ABC-file.RTF

    Size: 156.6 MB
    34%

Snippet

Additional Options

Mixed HTML Content

All alerts accept HTML as their content. You can use the following modifiers:

  • .lead inside of an alert to make the beginning of your message stand out
  • .alert-link to style a link inside your alert
Warning:This alert is awarning message.

Snippet

Dismissible Alerts

Success: This is a success closeable alert

Snippet

Alert Notifications Absolute

An absolute positioned container for placing alerts on the top right corner relative to .alert-container. Use this to create sticky positioned alerts with javascript, modifying the CSS property transform: translateY(); or margin-top when scrollY reaches a specific threshold. This component should generally be placed at the top of the page for sticky alerts aligned at the top.

Snippet

Fixed Notifications

A fixed positioned container for placing alerts on the top right corner of the page. This component can generally be placed anywhere on the page.

Snippet

Edit this page on GitHub

Contributors

Matuzalém Teles

Last edited May 12, 2025 at 7:56:02 PM