Skip to main content

Alert

The Alert component displays a message or feedback to the user, usually in response to an action or an event. The Alert component can have different severity levels, such as success, info, warning, or error, and can be styled accordingly. The Alert component can also be dismissed by the user or automatically after a certain time.

You can find the Alerts component in the src/views/Alerts.jsx file.

Examples

Alerts are available for any length of text, as well as an optional dismiss button. For proper styling, use one of the eight variants. Alert Preview

Result


For links, use the <Alert.Link> component to provide matching colored links within any alert. Alert Link Preview

Result


With Badge

Alerts can contain another component also like <Badge>. Alert Preview

Result


Additional content Alerts can contain whatever content you like. Headers, paragraphs,

dividers, go crazy. Alert Preview

Result

Props

NameTypeDefaultDescription
variant

primary, secondary, success, danger, warning, info, dark, light

A string that specifies the color scheme of the alert. You can choose from eight options: primary, secondary, success, danger, warning, info, dark, or light. The default value is primary.

dismissibleboolean

A boolean that indicates whether the alert can be closed by the user. If dismissible is true, a close button will appear on the right side of the alert. If dismissible is false, the alert will not have a close button. The default value is false.

showboolean

A boolean that indicates whether the alert is visible or not. If show is true, the alert will be rendered on the screen. If show is false, the alert will be hidden. The default value is true.

onClosefunc

A function that is called when the alert is closed by the user or by the timeout. The function receives the event object as the argument. You can use this prop to perform any action or logic when the alert is closed. For example, you can use onClose to update the state of the parent component or to trigger another alert. The default value is null.

For more props please visit to react-bootstrap