Alert

Display success, warning and error messages.

Alert

Display success, warning and error messages.

Usage

To apply this component, add the uk-alert attribute to a block element.

<div uk-alert></div>

Close button

To create a close button and enable its functionality, add the .uk-alert-close class to a <button> or <a> element inside the alert box. To apply a close icon, add the uk-close attribute from the Close component.

<div uk-alert>
    <a class="uk-alert-close" uk-close></a>
</div>

Style modifiers

There are several style modifiers available. Just add one of the following classes to apply a different look.

ClassDescription
.uk-alert-primaryGive the message a prominent styling.
.uk-alert-successIndicates success or a positive message.
.uk-alert-warningIndicates a message containing a warning.
.uk-alert-dangerIndicates an important or error message.

Component options

Any of these options can be applied to the component attribute. Separate multiple options with a semicolon. Learn more

OptionValueDefaultDescription
animationBooleantrueFade out or hide directly.
durationNumber150Animation duration in milliseconds.
sel-closeCSS selector.uk-alert-closeThe close trigger element.

animation is the Primary option and its key may be omitted, if it’s the only option in the attribute value.

<span uk-toggle=".my-class"></span>

JavaScript

Learn more about JavaScript components.

Initialization

UIkit.alert(element, options);

Events

The following events will be triggered on elements with this component attached:

NameDescription
beforehideFires before an item is hidden. Can prevent hiding by calling preventDefault() on the event.
hideFires after an item is hidden.

Methods

The following methods are available for the component:

Close

UIkit.alert(element).close();

Closes and removes the Alert.