AlertViewElement

An AlertViewElement writes a <div> element with the role "alert" to the output.

Element and builder

The AlertViewElement has an equivalent AlertViewElementBuilder. A builder can be created using BootstrapViewElements.bootstrap.builders.alert() factory methods.

AlertViewElement attributes

Attribute Description Default

Type

A AlertViewElement has the following default styles: INFO,WARNING,DANGER, SUCCESS

Not set by default

closeLabel

An aria-label shown for the close icon

Not set by default

dismissible

A boolean indicating if the AlertViewElement can be dismissed

False by default

Examples

Creating a simple alert

import static com.foreach.across.modules.bootstrapui.ui.factories.BootstrapViewElements.bootstrap;

bootstrap.builders
    .alert()
    .danger()
    .text( "This is a danger alert—check it out!\n" )
    .build();

Creating an alert with several options

import static com.foreach.across.modules.bootstrapui.ui.factories.BootstrapViewElements.bootstrap;

bootstrap.builders
    .alert()
    .closeLabel( "Close alert" )
    .dismissible( false )
    .success()
    .text( "This is a success alert—check it out!\n" )
    .build();