npm_versionnpm Paragon package page

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 VariableComputed Value










Props API#

Alert Props API
  • className string

    Specifies class name to append to the base element

  • bsPrefix string

    Overrides underlying component base CSS class name

  • variant 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light'

    Specifies variant to use.

  • transition boolean | TransitionComponent

    Animate the entering and exiting of the Alert. true will 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 boolean

    Whether the alert is shown.

    Defaulttrue
  • dismissible boolean

    Whether the alert is dismissible. Defaults to false.

    Defaultfalse
  • onClose () => void

    Optional callback function for when the alert it dismissed.

    Default() => {}
  • actions React.ReactElement[]

    Optional list of action elements. May include, at most, 2 actions, or 1 if dismissible is true.

  • stacked boolean

    Position of the dismiss and call-to-action buttons. Defaults to false.

    Defaultfalse
  • closeLabel string | ReactNode

    Sets the text for alert close button, defaults to 'Dismiss'.

AlertHeading Props API
  • as ElementType

    Specifies the base element

    DefaultdivWithClassName('h4')
  • bsPrefix string

    Overrides underlying component base CSS class name

    Default'alert-heading'
  • children ReactNode

Usage Insights#

Alert

Project NameParagon VersionInstance Count
edx-ora2
21.13.1
2
frontend-app-account
22.10.0
8
frontend-app-admin-portal
21.13.1
70
frontend-app-authn
22.11.2
9
frontend-app-communications
22.7.0
3
frontend-app-course-authoring
22.8.1
32
ora_settings
22.8.1
1
proctoring
22.8.1
3
xpert_unit_summary
22.8.1
1
frontend-app-discussions
22.7.0
3
frontend-app-ecommerce
20.46.3
2
frontend-app-enterprise-public-catalog
21.13.1
2
frontend-app-gradebook
22.8.1
5
frontend-app-learner-dashboard
22.9.0
2
frontend-app-learner-portal-enterprise
21.13.1
22
frontend-app-learner-portal-programs
21.13.1
5
frontend-app-learner-record
22.10.0
5
frontend-app-learning
22.10.0
24
frontend-app-library-authoring
21.11.3
7
frontend-app-ora-grading
21.11.3
5
frontend-app-payment
22.9.0
1
frontend-app-profile
22.10.0
3
frontend-app-program-console
21.13.1
5
frontend-app-publisher
21.13.1
25
frontend-app-support-tools
21.13.1
18
frontend-lib-special-exams
22.7.0
4
prospectus
20.46.2
3

AlertHeading

Project NameParagon VersionInstance Count
frontend-app-account
22.10.0
2
frontend-app-admin-portal
21.13.1
49
frontend-app-authn
22.11.2
8
frontend-app-communications
22.7.0
1
frontend-app-course-authoring
22.8.1
11
ora_settings
22.8.1
1
xpert_unit_summary
22.8.1
1
frontend-app-ecommerce
20.46.3
2
frontend-app-enterprise-public-catalog
21.13.1
1
frontend-app-learner-portal-enterprise
21.13.1
9
frontend-app-learner-record
22.10.0
2
frontend-app-learning
22.10.0
3
frontend-app-library-authoring
21.11.3
1
frontend-app-ora-grading
21.11.3
4
frontend-app-profile
22.10.0
1
frontend-app-publisher
21.13.1
4
frontend-app-support-tools
21.13.1
2
frontend-lib-special-exams
22.7.0
2
prospectus
20.46.2
1

AlertLink

Project NameParagon VersionInstance Count
frontend-app-account
22.10.0
1
frontend-app-authn
22.11.2
4
frontend-app-course-authoring
22.8.1
7
proctoring
22.8.1
5
frontend-app-enterprise-public-catalog
21.13.1
1
frontend-app-learner-portal-enterprise
21.13.1
2
frontend-app-learner-portal-programs
21.13.1
1
frontend-app-profile
22.10.0
1
frontend-lib-special-exams
22.7.0
3