Alerts help draw attention to brief confirmation or warning messages—or any other important information—that shouldn't be overlooked while your visitor scans the page.
Accessibility Spotlight
When modifying alert colors, be sure to check that your colors meet a sufficient contrast ratio.
Never rely on color alone to convey meaning. Include a visual icon in alerts for those who experience colors differently.
Include an appropriate alert role for assistive technology.
Confirm and Warn
The Natura11y provides two types of alerts: Confirm implied with green, and Warn implied with red.
Every instance of an alert should include an icon to help convey meaning. Across the Framework Natura11y Icons, our open-source icon library, is used for all icons.
The .alert__title__text selector holds the alert title's text. It is required. It
includes the unique id targeted by the aria-labelledby attribute
present on the .alert selector.
It holds the alert's description message. It includes the unique id targeted by the aria-describedby attribute present on the .alert selector.
All links (<a> tags) within the <p> tags, will automatically inherit the alert's text color.
Inverse Color Modifier
For a bolder look, chain --inverse to the alert--confirm or alert--warn modifier classes respectively.
Title Only Alert
The .alert__description is not required. Leaving it out creates a title only alert.
Dismissable Alerts
For dismissable alerts, add the .alert--dismissable modifier class. Doing so automatically places a close button inside the .alert.
When the close button is pressed, the alert fades out, then the entire .alert selector is removed
from the DOM.
More Style Variations
Looking for even more alert styles? Exclude the .alert--confirm or .alert--warn
modifier classes. Instead, add the color utilities or border utilities for different accents and style
variations.
Related CSS Variables
Further customize Alerts by redefining any of their related CSS variables as shown below.