Alert
- HTML/CSS:Dev Ready
- Layout:Responsive
Sections
Logged in as John Smith (johnsmith@acme.com). Log out
About Alert#
Accessibility#
Role#
Alert notifications should contain role="alert"
on the container to signal to assistive technology that they require the user’s immediate attention.
<div class="slds-notify slds-notify_alert" role="alert">...</div>
Assistive Text#
Use a span with the class slds-assistive-text
to let the user know what type of notification it is.
<span class="slds-assistive-text">Info</span>
Base#
Use the info alert when notifying the user of neutral information about the system.
Logged in as John Smith (johnsmith@acme.com). Log out
<div class="slds-notify slds-notify_alert" role="alert">
<span class="slds-assistive-text">info</span>
<span class="slds-icon_container slds-icon-utility-user slds-m-right_x-small" title="Description of icon when needed">
<svg class="slds-icon slds-icon_x-small" aria-hidden="true">
Variations#
Warning#
Use the warning variant to warn the user about important system information that deserves caution.
Your browser is outdated. Your Salesforce experience may be degraded. More Information
<div class="slds-notify slds-notify_alert slds-alert_warning" role="alert">
<span class="slds-assistive-text">warning</span>
<span class="slds-icon_container slds-icon-utility-warning slds-m-right_x-small" title="Description of icon when needed">
<svg class="slds-icon slds-icon_x-small" aria-hidden="true">
Error#
Use the error variant when you need to alert the user about an error in the system that needs immediate attention.
Your browser is currently not supported. Your Salesforce may be degraded. More Information
<div class="slds-notify slds-notify_alert slds-alert_error" role="alert">
<span class="slds-assistive-text">error</span>
<span class="slds-icon_container slds-icon-utility-error slds-m-right_x-small" title="Description of icon when needed">
<svg class="slds-icon slds-icon_x-small" aria-hidden="true">
Offline#
Use the offline alert to let the user know that they are not connected to the internet.
You are in offline mode. More Information
<div class="slds-notify slds-notify_alert slds-alert_offline" role="alert">
<span class="slds-assistive-text">offline</span>
<span class="slds-icon_container slds-icon-utility-offline slds-m-right_x-small" title="Description of icon when needed">
<svg class="slds-icon slds-icon_x-small" aria-hidden="true">
Styling Hooks Overview#
Use these CSS Custom Properties as hooks to customize this SLDS component with your own style. For more information, read the technical documentation.
Category | Styling Hook Name | Value Type(s) | Fallback Value |
---|---|---|---|
Box Shadow | --slds-c-alert-shadow | String | 0 0 3px #f3f3f3 |
Color | --slds-c-alert-color-background | Color | #747474 |
--slds-c-alert-color-border | Color | #f3f3f3 | |
--slds-c-alert-text-color | Color | white | |
--slds-c-alert-text-color-active | Color | rgba(255, 255, 255, 0.5) | |
Image | --slds-c-alert-image-background | Image | linear-gradient(45deg, rgba(0, 0, 0, 0.025) 25%, transparent 25%, transparent 50%, rgba(0, 0, 0, 0.025) 50%, rgba(0, 0, 0, 0.025) 75%, transparent 75%, transparent) |
--slds-c-alert-size-background | String, Dimension | 64px 64px | |
Sizing | --slds-c-alert-sizing-border | Dimension | 1px |
Spacing | --slds-c-alert-spacing-block-end | Dimension | 0.5rem |
--slds-c-alert-spacing-block-start | Dimension | 0.5rem | |
--slds-c-alert-spacing-inline-end | Dimension | 2rem | |
--slds-c-alert-spacing-inline-start | Dimension | 0.5rem | |
Text | --slds-c-alert-font-weight | String, Number |
Overview of CSS Classes#
- Selector
- The CSS class being referred to.
- Summary
- A description of what the class does.
- Support
- Whether the class name is dev-ready (meaning it's fully vetted and tested and safe to use) or prototype (which means it's not fully vetted yet).
- Restrict
- The selector that the class name is allowed to be used on.
- Variant
- The base level pattern for a component. A variant can be extended to create another variant of that component, for example, a stateful button is a derivative of the base button.
- Modifier
- A single class that can be added to an HTML element of a component to modify its output. Typically these will be colors, sizing and positioning.
Selector | .slds-notify_alert |
---|---|
Summary | Initializes alert notification |
Support | dev-ready |
Restrict | div |
Variant | True |
Selector | .slds-alert_warning |
---|---|
Summary | Sets styling for warning alert notification |
Restrict | .slds-notify_alert |
Selector | .slds-alert_error |
---|---|
Summary | Sets styling for error alert notification |
Restrict | .slds-notify_alert |
Selector | .slds-alert_offline |
---|---|
Summary | Sets styling for offline alert notification |
Restrict | .slds-notify_alert |
Selector | .slds-notify__close |
---|---|
Summary | Alert close button |
Restrict | .slds-notify_alert div |
Alert Release Notes
2.17.0
Added
- Added
slds
as the default namespace withsds
fallbacks for Styling Hooks. - Added reassignment of Styling Hooks for component states.
2.14.0
Fixed
- Fix incorrect Styling Hook name for
--sds-c-alert-text-color-warning
.
Removed
- Removed component level styling hooks for status states.
2.13.3
Changed
- Treat Styling Hooks targeting text color as an element, previously referred to as a property. e.g.
--sds-c-alert-color-text
=>--sds-c-alert-text-color
.
2.14.0
Changed
Refactored the component markup to function with or without theme utility classes.
2.13.0
Added
- Enabled styling hooks for alert. See alert's styling hooks overview table for a full listing of the currently available hooks.
2.8.0
Fixed
- Added
slds-button_icon-small
to the close button on alerts to fix the sizing of the click target. - Improved the contrast for focus and hover states on links and buttons in alerts
2.7.0
Changed
- Changed HTML so the button icon can be slotted into the
slds-notify__close
element
Fixed
- Buttons with the new BEM syntax used within an inverse themed component no longer have their text color overridden