ButtonViewElement

A ButtonViewElement writes a <button> element to the output.

Element and builder

The ButtonViewElement has an equivalent ButtonViewElementBuilder. A builder can be created using BootstrapUiBuilders.button() factory methods.

ButtonViewElement attributes

Attribute Description Default

Type

A ButtonViewElement can have the following type: BUTTON, BUTTON_SUBMIT, BUTTON_RESET, INPUT, INPUT_SUBMIT, INPUT_RESET,LINK

BUTTON

State

A ButtonViewElement can have the following states: ACTIVE, DISABLED

ACTIVE

Icon

A GlyphIcon can be provided to show on the button. It can be aligned left, right or set as iconOnly.

Not set by default

Link

Transform the ButtonViewElement into a link.

Not set by default

Examples

Creating a simple button

Given the following builder configuration

BootstrapUiBuilders
    .button()
    .text( "Click me" )
    .build();

The following markup would be rendered:

<button type="button" class="btn btn-default">Click me</button>

Given the following builder configuration

BootstrapUiBuilders
    .button()
    .text( "To google  " )
    .link( "http://www.foreach.be" )
    .iconRight()
    .icon( BootstrapUiBuilders.glyphIcon( GlyphIcon.ARROW_RIGHT ))
    .build();

The following markup would be rendered:

<a role="button" href="http://www.foreach.be" class="btn btn-link">To google  <span aria-hidden="true" class="glyphicon glyphicon-arrow-right"></span></a>

Large submit button

Given the following builder configuration

BootstrapUiBuilders
    .button()
    .submit()
    .size(Size.LARGE )
    .text( "Submit" )
    .build();

The following markup would be rendered:

<button type="submit" class="btn btn-default btn-lg">Submit</button>