The Alert component displays a short, important message in a way that attracts the user's attention.
Alerts offer four severity levels that set a distinctive icon and color:
- Info: used to convey general information or actions that aren't critical, note that info variant should not contain any icons in it
- Warning: used to display information that needs attention
- Success: used for success messages
- Danger: used to communicate problems that have to be resolved immediately
This component utilizes and extends the Alert component from react-bootstrap.
See React-Bootstrap for additional documentation.
Basic Usage
Any Paragon component or export may be added to the code example.
With Action Buttons
The Alert component supports a dismissible button and a custom call-to-action button, via the dismissible and button props respectively. The buttons may be right aligned or stacked. On extra small screen widths, the buttons will be stacked.
The stacked variant should be used for:
- Placement in sidebars or small container
- Extra-small breakpoint and below
Any Paragon component or export may be added to the code example.
Variants
Any Paragon component or export may be added to the code example.
Kitchen Sink
Any Paragon component or export may be added to the code example.
Theme Variables#
| CSS Variable | Computed Value |
|---|---|
| | |
| | |
| | |
| | |
| | |
Props API#
- className
stringSpecifies class name to append to the base element
- bsPrefix
stringOverrides underlying component base CSS class name
- variant
'primary'|'secondary'|'success'|'danger'|'warning'|'info'|'dark'|'light'Specifies variant to use.
- transition
boolean|TransitionComponentAnimate the entering and exiting of the Alert.
truewill use the<Fade>transition, more detailed customization is also provided. - children
ReactNode - icon
React.ComponentType<IconProps>Icon that will be shown in the alert
- show
booleanDefaulttrueWhether the alert is shown.
- dismissible
booleanDefaultfalseWhether the alert is dismissible. Defaults to false.
- onClose
() => voidDefault() => {}Optional callback function for when the alert it dismissed.
- actions
React.ReactElement[]Optional list of action elements. May include, at most, 2 actions, or 1 if dismissible is true.
- stacked
booleanDefaultfalsePosition of the dismiss and call-to-action buttons. Defaults to
false. - closeLabel
string|ReactNodeSets the text for alert close button, defaults to 'Dismiss'.
- as
ElementTypeDefaultdivWithClassName('h4')Specifies the base element
- bsPrefix
stringDefault'alert-heading'Overrides underlying component base CSS class name
- children
ReactNode
- as
ElementTypeDefault'a'Specifies the base element
- bsPrefix
stringDefault'alert-link'Overrides underlying component base CSS class name
- children
ReactNode - href
string
Usage Insights#
Alert
| Project Name | Paragon Version | Instance Count | |
|---|---|---|---|
| edx-ora2 | 21.13.1 | 2 | |
| frontend-app-account | 23.14.8 | 8 | |
| frontend-app-admin-portal | 22.20.3 | 69 | |
| frontend-app-communications | 23.14.2 | 3 | |
| frontend-app-course-authoring | 23.15.1 | 31 | |
| ora_settings | 23.15.1 | 1 | |
| proctoring | 23.15.1 | 3 | |
| xpert_unit_summary | 23.15.1 | 1 | |
| frontend-app-discussions | 23.14.2 | 3 | |
| frontend-app-ecommerce | 20.46.3 | 2 | |
| frontend-app-enterprise-public-catalog | 22.20.5 | 2 | |
| frontend-app-gradebook | 23.4.5 | 4 | |
| frontend-app-learner-portal-enterprise | 22.17.0 | 22 | |
| frontend-app-learner-portal-programs | 22.20.6 | 1 | |
| frontend-app-learner-record | 23.14.9 | 6 | |
| frontend-app-gradebook | 23.4.5 | 8 | |
| frontend-app-learner-record | 23.4.5 | 6 | |
| frontend-app-payment | 22.9.0 | 1 | |
| frontend-app-profile | 23.14.9 | 2 | |
| frontend-app-program-console | 21.13.1 | 2 | |
| frontend-app-publisher | 23.14.8 | 27 | |
| frontend-app-support-tools | 23.4.2 | 18 | |
| frontend-lib-special-exams | 23.4.2 | 4 |
AlertHeading
| Project Name | Paragon Version | Instance Count | |
|---|---|---|---|
| frontend-app-account | 23.14.8 | 2 | |
| frontend-app-admin-portal | 22.20.3 | 49 | |
| frontend-app-authn | 23.15.2 | 8 | |
| frontend-app-communications | 23.14.2 | 1 | |
| frontend-app-course-authoring | 23.15.1 | 11 | |
| ora_settings | 23.15.1 | 1 | |
| xpert_unit_summary | 23.15.1 | 1 | |
| frontend-app-ecommerce | 20.46.3 | 2 | |
| frontend-app-enterprise-public-catalog | 22.20.5 | 1 | |
| frontend-app-learner-portal-enterprise | 22.17.0 | 9 | |
| frontend-app-learner-record | 23.14.9 | 3 | |
| frontend-app-learning | 23.4.5 | 3 | |
| frontend-app-publisher | 23.14.8 | 7 | |
| frontend-app-support-tools | 23.4.2 | 2 | |
| frontend-lib-special-exams | 23.4.2 | 2 |
AlertLink
| Project Name | Paragon Version | Instance Count | |
|---|---|---|---|
| frontend-app-account | 23.14.8 | 1 | |
| frontend-app-authn | 23.15.2 | 9 | |
| frontend-app-course-authoring | 23.15.1 | 8 | |
| proctoring | 23.15.1 | 5 | |
| frontend-app-enterprise-public-catalog | 22.20.5 | 1 | |
| frontend-app-gradebook | 23.4.5 | 5 | |
| frontend-app-learner-portal-enterprise | 22.17.0 | 2 | |
| frontend-lib-special-exams | 23.4.2 | 3 |