React Alert Component

Alert

Rocket
New Year sale. Skyrocket your business in 2025!
Extra 25% off for all sale items + Free CoreUI Icons PRO with every order!
Limited-time offer for the first 100 customers in 2025. Use code 2025SKY25 at checkout.

React alert component gives contextual feedback information for common user operations. The alert component is delivered with a bunch of usable and adjustable alert messages.

Other Frameworks

CoreUI components are available as native Angular, Bootstrap (Vanilla JS), and Vue components. To learn more please visit the following pages.

How to use React Alert Component.#

React Alert is prepared for any length of text, as well as an optional close button. For a styling, use one of the required contextual color props (e.g., primary). For inline dismissal, use the dismissing prop.

Conveying meaning to assistive technologies

Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies – such as screen readers. Ensure that information denoted by the color is either obvious from the content itself (e.g. the visible text), or is included through alternative means, such as additional text hidden with the .visually-hidden class.

Live example#

Click the button below to show an alert (hidden with inline styles to start), then dismiss (and destroy) it with the built-in close button.

Use the <CAlertLink> component to immediately give matching colored links inside any react alert component.

Additional content#

React Alert can also incorporate supplementary components & elements like heading, paragraph, and divider.

Icons#

Similarly, you can use flexbox utilities and CoreUI Icons to create react alerts with icons. Depending on your icons and content, you may want to add more utilities or custom styles.

Need more than one icon for your react alerts? Consider using CoreUI Icons.

Solid#

Use variant="solid" to change contextual colors to solid.

Dismissing#

React Alert component can also be easily dismissed. Just add the dismissible prop.

When an alert is dismissed, the element is completely removed from the page structure. If a keyboard user dismisses the alert using the close button, their focus will suddenly be lost and, depending on the browser, reset to the start of the page/document.

API#

Check out the documentation below for a comprehensive guide to all the props you can use with the components mentioned here.