Alerts
Provide contextual feedback messages for typical user actions with the handful of available and flexible alert messages.
Examples
Alerts are available for any length of text, as well as an optional
dismiss button. For proper styling, use one of the eight variant
s.
Links
For links, use the <Alert.Link>
component to provide matching
colored links within any alert.
Additional content
Alerts can contain whatever content you like. Headers, paragraphs, dividers, go crazy.
Aww yeah, you successfully read this important alert message. This example text is going to run a bit longer so that you can see how spacing within an alert works with this kind of content.
Whenever you need to, be sure to use margin utilities to keep things nice and tidy.
Dismissing
Add the dismissible
prop to add a functioning dismiss
button to the Alert.
Change this and that and try again. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus sit amet fermentum.
You can also control the visual state directly which is great if you want to build more complicated alerts.
Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus sit amet fermentum.
API
Alertview source file
import Alert from 'react-bootstrap/Alert'
Copy import code for the Alert componentName | Type | Default | Description |
---|---|---|---|
closeLabel | string | 'Close alert' | Sets the text for alert close button. |
closeVariant | 'white' | Sets the variant for close button. | |
dismissible | boolean | Renders a properly aligned dismiss button, as well as adding extra horizontal padding to the Alert. | |
onClose | function | controls show Callback fired when alert is closed. | |
show | boolean | true | controlled by: onClose , initial prop: defaultShow Controls the visual state of the Alert. |
transition | boolean | elementType | Fade | Animate the alert dismissal. Defaults to using |
variant | 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light' | The Alert visual variant | |
bsPrefix | string | 'alert' | Change the underlying component CSS base class name and modifier class names prefix. This is an escape hatch for working with heavily customized bootstrap css. |
Alert.Headingview source file
import Alert from 'react-bootstrap/Alert'
Copy import code for the Alert componentName | Type | Default | Description |
---|---|---|---|
as | elementType | <DivStyledAsH4> | You can use a custom element type for this component. |
bsPrefix required | string | 'alert-heading' | Change the underlying component CSS base class name and modifier class names prefix. This is an escape hatch for working with heavily customized bootstrap css. |
Alert.Linkview source file
import Alert from 'react-bootstrap/Alert'
Copy import code for the Alert componentName | Type | Default | Description |
---|---|---|---|
as | elementType | <SafeAnchor> | You can use a custom element type for this component. |
bsPrefix required | string | 'alert-link' | Change the underlying component CSS base class name and modifier class names prefix. This is an escape hatch for working with heavily customized bootstrap css. |