Provide contextual feedback messages for typical user actions with the handful of available and flexible alert messages.
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.
For links, use the <Alert.Link>
component to provide matching colored links within any alert.
Alerts can contain whatever content you like. Headers, paragraphs, dividers, go crazy.
Add the dismissible
prop to add a functioning dismiss button to the Alert.
You can also control the visual state directly which is great if you want to build more complicated alerts.
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. |
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. |
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. |
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. |
© 2014–present Stephen J. Collings, Matthew Honnibal, Pieter Vanderwerff
Licensed under the MIT License (MIT).
https://react-bootstrap.github.io/components/alerts/