Skip to main content
HomeComponentsAlert
warning
This is a beta release of the Quantum web libraries
Please be careful when using them in production, as they may contain bugs, unstable breaking changes, and incomplete features.

Alert

Alerts inform the user of important information or important action required. They are non-disruptive to a user's experience and do not require to interrupt the user's task.

Basic alerts

Alert severity

The alert offers five severity levels that set a distinctive icon and color.

error_outline
This is an error alert — check it out!
warning_amber
This is a warning alert — check it out!
check_circle
This is a success alert — check it out!
info
This is an informative alert — check it out!
info
This is a neutral alert — check it out!
<Alert
message="This is an error alert — check it out!"
severity="error"
dismissible={false}
></Alert>
<Alert
message="This is a warning alert — check it out!"
severity="warning"
dismissible={false}
></Alert>
<Alert
message="This is a success alert — check it out!"
severity="success"
dismissible={false}
></Alert>
<Alert
message="This is an informative alert — check it out!"
severity="informative"
dismissible={false}
></Alert>
<Alert
message="This is a neutral alert — check it out!"
severity="neutral"
dismissible={false}
></Alert>

Title

You can use title property to display a formatted title.

info
Title
This is an informative alert — check it out!
<Alert
message="This is an informative alert — check it out!"
severity="informative"
title="Title"
dismissible={false}
></Alert>

Message

You can use message property or children to display a formatted message.

error_outline
Error

This is an error alert — check it out!

<Alert severity="error" title="Error" dismissible={false}>
This is an error alert — <strong>check it out!</strong>
</Alert>

Action buttons

An alert can have actions, such as a close or undo button. It is rendered after the message, at the end of the alert. To add action buttons to an alert, set actionButtons property to an array of action buttons.

By default a close button is displayed. You can remove it by setting the dismissible prop to false.

info
This is an informative alert — check it out!
<Alert
message="This is an informative alert — check it out!"
severity="informative"
actionButtons={[{ text: 'UNDO', icon: 'undo', onClick: () => {} }]}
onClose={() => console.log('Alert closed')}
></Alert>

Icons

You can change the default severity to icon mapping with the iconMapping prop.

By default, the iconMapping has the following format:

{
informative: 'info',
success: 'check_circle',
error: 'error_outline',
warning: 'warning_amber',
};
done
This is a success alert
<Alert
message="This is a success alert"
severity="success"
dismissible={false}
iconMapping={{ success: 'done' }}
></Alert>

Color

The color prop will override the default color for the specified severity.

info
This is an alert with an error color — check it out!
info
This is an alert with a warning color — check it out!
info
This is an alert with a success color — check it out!
info
This is an alert with an informative — check it out!
info
This is an alert with a neutral color — check it out!
<Alert
message="This is an alert with an error color — check it out!"
color="error"
dismissible={false}
></Alert>
<Alert
message="This is an alert with a warning color — check it out!"
color="warning"
dismissible={false}
></Alert>
<Alert
message="This is an alert with a success color — check it out!"
color="success"
dismissible={false}
></Alert>
<Alert
message="This is an alert with an informative — check it out!"
color="informative"
dismissible={false}
></Alert>
<Alert
message="This is an alert with a neutral color — check it out!"
color="neutral"
dismissible={false}
></Alert>

Low / Medium / High emphasis

The Quantum supports three levels of emphasis style alerts. High-emphasis alerts are best for critical messaging while low-emphasis and mid-emphasis alerts are less visually disruptive for users.

The emphasis prop will change the emphasis style alert.

Error color

error_outline
This is an error alert with low emphasis — check it out!
error_outline
This is an error alert with medium emphasis — check it out!
error_outline
This is an error alert with high emphasis — check it out!

Warning color

warning_amber
This is a warning alert with low emphasis — check it out!
warning_amber
This is a warning alert with medium emphasis — check it out!
warning_amber
This is a warning alert with high emphasis — check it out!

Success color

check_circle
This is a success alert with low emphasis — check it out!
check_circle
This is a success alert with medium emphasis — check it out!
check_circle
This is a success alert with high emphasis — check it out!

Informative color

info
This is an informative alert with low emphasis — check it out!
info
This is an informative alert with medium emphasis — check it out!
info
This is an informative alert with high emphasis — check it out!

Neutral color

info
This is an informative alert with low emphasis — check it out!
info
This is a informative alert with medium emphasis — check it out!
info
This is a informative alert with high emphasis — check it out!
<Alert
message="This is an error alert with low emphasis — check it out!"
severity="error"
emphasis="low"
></Alert>
<Alert
message="This is an error alert with medium emphasis — check it out!"
severity="error"
emphasis="medium"
></Alert>
<Alert
message="This is an error alert with high emphasis — check it out!"
severity="error"
emphasis="high"
></Alert>

Size

For larger or smaller alerts, use the size prop

info
Title
This is an informative alert — check it out!
info
Title
This is an informative alert — check it out!
info
Title
This is an informative alert — check it out!
<Alert
message="This is an informative alert — check it out!"
severity="informative"
title="Title"
size="small"
></Alert>
<Alert
message="This is an informative alert — check it out!"
severity="informative"
title="Title"
size="medium"
></Alert>
<Alert
message="This is an informative alert — check it out!"
severity="informative"
title="Title"
size="large"
></Alert>

API

The Alert component accepts all the props a standard <div> does in React (HTML, ARIA, data attributes, event handlers, and children). Its props are typed as React.HTMLAttributes<HTMLDivElement>. See more about supported HTML props in React's documentation.

Loading API documentation...

Spotted a bug, have a question, or want to suggest a new feature?

Submit an issue on GitLab