Button

in namespace DotVVM.Bootstrap5.Controls

Extends the built-in Button control to allow applying Bootstrap CSS classes to the button.

Usage & Scenarios

Extends the built-in Button control to allow applying Bootstrap CSS classes to the button and sizes.

https://getbootstrap.com/docs/5.2/components/buttons/

Sample 1: Button Sizing

Use the Size property to set the size of the button.

<bs:Button Click="{command: DoSomething()}" 
           Text="Button" />

<bs:Button Click="{command: DoSomething()}" 
           Text="Button" 
           Size="Large" />

<bs:Button Click="{command: DoSomething()}" 
           Text="Button" 
           Size="Small" />
public class ViewModel : DotvvmViewModelBase
{

    public void DoSomething()
    {
    }
}

Sample 2: Button Types

The Type property specifies the color of the button (using standard Bootstrap classes).

<bs:Button Click="{command: DoSomething()}" 
           Text="Primary" 
           Type="Primary" />

<bs:Button Click="{command: DoSomething()}" 
           Text="Secondary" 
           Type="Secondary" />

<bs:Button Click="{command: DoSomething()}" 
           Text="Success" 
           Type="Success" />

<bs:Button Click="{command: DoSomething()}" 
           Text="Danger" 
           Type="Danger" />

<bs:Button Click="{command: DoSomething()}" 
           Text="Warning" 
           Type="Warning" />

<bs:Button Click="{command: DoSomething()}" 
           Text="Info" 
           Type="Info" />

<bs:Button Click="{command: DoSomething()}" 
           Text="Light" 
           Type="Light" />

<bs:Button Click="{command: DoSomething()}" 
           Text="Dark" 
           Type="Dark" />

<bs:Button Click="{command: DoSomething()}" 
           Text="Link" 
           Type="Link" />
public class ViewModel : DotvvmViewModelBase
{

    public void DoSomething()
    {
    }
}

Sample 3: Button Shapes

The VisualStyle property allows to switch between buttons with solid fill and outline buttons.

<bs:Button Click="{command: DoSomething()}" 
           Text="Solid Fill" 
           Type="Primary" 
           VisualStyle="SolidFill" />

<bs:Button Click="{command: DoSomething()}" 
           Text="Outline" 
           Type="Primary" 
           VisualStyle="Outline" />
public class ViewModel : DotvvmViewModelBase
{

    public void DoSomething()
    {
    }
}

Sample 5: FontType

The FontType property specifies the color of the text inside of the button (using standard Bootstrap classes).

<bs:Button Click="{command: DoSomething()}" 
           Type="Light" 
           FontType="Primary" 
           Text="Text"  />

<bs:Button Click="{command: DoSomething()}" 
           Type="Light" 
           FontType="Secondary" 
           Text="Text"  />

<bs:Button Click="{command: DoSomething()}" 
           Type="Light" 
           FontType="Success" 
           Text="Text"  />

<bs:Button Click="{command: DoSomething()}" 
           Type="Light" 
           FontType="Danger" 
           Text="Text"  />

<bs:Button Click="{command: DoSomething()}" 
           Type="Light" 
           FontType="Warning" 
           Text="Text"  />

<bs:Button Click="{command: DoSomething()}" 
           Type="Light" 
           FontType="Info" 
           Text="Text"  />

<bs:Button Click="{command: DoSomething()}" 
           Type="Dark" 
           FontType="Light" 
           Text="Text"  />

<bs:Button Click="{command: DoSomething()}" 
           Type="Light" 
           FontType="Dark" 
           Text="Text"  />

<bs:Button Click="{command: DoSomething()}" 
           Type="Dark" 
           FontType="White" 
           Text="Text"  />

<bs:Button Click="{command: DoSomething()}" 
           Type="Dark" 
           FontType="Muted" 
           Text="Text"  />

<bs:Button Click="{command: DoSomething()}" 
           Type="Dark" 
           FontType="WhiteOpacity" 
           Text="Text"  />

<bs:Button Click="{command: DoSomething()}" 
           Type="Light" 
           FontType="BlackOpacity" 
           Text="Text"  />

<bs:Button Click="{command: DoSomething()}" 
           Type="Light" 
           FontType="Body" 
           Text="Text"  />
public class ViewModel : DotvvmViewModelBase
{

    public void DoSomething()
    {
    }
}

Properties

Name Type Description Notes Default Value
property icon ButtonTagName ButtonTagName Gets or sets whether the control should render the input or the button tag in the HTML.
attribute
inner element
static value
bindable
default
button
property icon Content List<DotvvmControl> Gets or sets the content placed inside the control.
attribute
inner element
static value
bindable
default
null
property icon Enabled Boolean Gets or sets a button disabled state.
attribute
inner element
static value
bindable
default
True
property icon FontType ButtonTextColor Gets or sets the button font color.
attribute
inner element
static value
bindable
default
Default
property icon IsSubmitButton Boolean Gets or sets whether the control should render a submit button or a normal button (type="submit" or type="button"). The submit button has some special features in the browsers, e.g. handles the Return key in HTML forms etc.
attribute
inner element
static value
bindable
default
False
property icon Size Size Gets or sets the button size. Possible values are `Small` `Default` and `Large`.
attribute
inner element
static value
bindable
default
Default
property icon Text String Gets or sets the text inside the control.
attribute
inner element
static value
bindable
default
null
property icon Type ButtonType Gets or sets the button type.
attribute
inner element
static value
bindable
default
Primary
property icon Visible Boolean Gets or sets whether the control is visible. When set to false, `style="display: none"` will be added to this control.
attribute
inner element
static value
bindable
default
True
property icon VisualStyle ButtonVisualStyle Gets or sets the button visual style. Possible values are `SolidFill` and `Outline`.
attribute
inner element
static value
bindable
default
SolidFill

Events

Name Type Description
event icon Click ICommandBinding Gets or sets the command that will be triggered when the button is clicked.

HTML produced by the control