Theme

PlaygroundBeta

npm_versionnpm Paragon package page

StatusAlert

basic usage

Any Paragon component or export may be added to the code example.

<StatusAlert
dialog="You have a status alert!"
onClose={() => {}}
open
/>

success alert

Any Paragon component or export may be added to the code example.

<StatusAlert
alertType="success"
dialog="Success!"
onClose={() => {}}
open
/>

danger alert

Any Paragon component or export may be added to the code example.

<StatusAlert
alertType="danger"
dialog="Error!"
onClose={() => {}}
open
/>

informational alert

Any Paragon component or export may be added to the code example.

<StatusAlert
alertType="info"
dialog="Get some info here!"
onClose={() => {}}
open
/>

alert with a custom aria-label on the close button

Any Paragon component or export may be added to the code example.

<StatusAlert
alertType="info"
dialog="Some very specific information."
onClose={() => {}}
open
closeButtonAriaLabel="Dismiss this very specific information."
/>

Non-dismissible alert

Any Paragon component or export may be added to the code example.

<StatusAlert
alertType="danger"
dismissible={false}
dialog="You can't get rid of me!"
open
/>

alert invoked via a button

Any Paragon component or export may be added to the code example.

class StatusAlertWrapper extends React.Component {
constructor(props) {
super(props);
this.openStatusAlert = this.openStatusAlert.bind(this);
this.resetStatusAlertWrapperState = this.resetStatusAlertWrapperState.bind(
this,
);
this.state = { open: false };
}
openStatusAlert() {
this.setState({ open: true });
}
resetStatusAlertWrapperState() {
this.setState({ open: false });
this.button.focus();
}
render() {
return (
<div>
<StatusAlert
alertType="warning"
open={this.state.open}
dialog="You triggered a warning"
onClose={this.resetStatusAlertWrapperState}
/>
<Button
onClick={this.openStatusAlert}
variant="light"
inputRef={input => {
this.button = input;
}}
>
Click me to open a Status Alert!
</Button>
</div>
);
}
}

Any Paragon component or export may be added to the code example.

<StatusAlert
alertType="info"
dialog={
<div>
<span>Love cats? </span>
<a
href="https://www.factretriever.com/cat-facts"
target="_blank"
rel="noopener noreferrer"
>
Click me!
</a>
</div>
}
onClose={() => {}}
open
/>

Props API#

StatusAlert Props API
  • alertType string

    specifies the type of alert that is being diplayed. It defaults to "warning". See the other available bootstrap options.

    Default'warning'
  • className string

    is a string array that defines the classes to be used within the status alert.

  • dialog string | element Required
  • dismissible bool

    specifies if the status alert will include the dismissible X button to close the alert. It defaults to true.

    Defaulttrue
  • closeButtonAriaLabel string
    Default'Close'
  • onClose isRequiredIf(PropTypes.func, props => props.dismissible)

    is a function that is called on close. It can be used to perform actions upon closing of the status alert, such as restoring focus to the previous logical focusable element. It is only required if dismissible is set to true and not required if the alert is not dismissible.

  • open bool

    specifies whether the status alert renders open or closed on the initial render. It defaults to false.

    Defaultfalse

Usage Insights#

StatusAlert

Project NameParagon VersionInstance Count
edx-platform2.6.410
frontend-app-admin-portal20.26.31
frontend-component-cookie-policy-banner12.0.51
frontend-learner-portal-base12.2.04
prospectus20.32.33
studio-frontend3.4.83