Skip to content

Buttons and forms

Checkbox

checkbox is a box the player ticks, such as a rule to turn on. Its label stands beside the box, as MudBlazor draws it, and confirm or a click ticks it. Bind it to a state and the state keeps whether it is ticked.

Examples

Bound to a state

checkbox "Auto Dash", bind: :dash
checkbox "Dungeon Navi", bind: :navi

Two boxes, one ticked

Three states

checkbox "Skip loss scenes", bind: :skip_loss, tri_state: true

A box that holds neither

With tri_state: true a click goes from off to on, then to neither, which the state holds as nil and the box shows as a bar, and back to off, such as the game's own choice of seeing every loss scene, skipping those seen, or asking each time.

Required

form on_submit: -> { reset_options } do
  checkbox "Reset every option", bind: :sure, required: "Tick it to reset"
  button "Defaults", on_click: :submit
end

A box with its error under it

A required box must be ticked. Its error shows under it, as on every input; see Form.

Params, events and keys

Every part also takes the params every part takes.

A box the player ticks, with its label beside it, such as a rule to turn on; with tri_state: true it may also hold neither.

Written checkbox label, ....

Param Takes Default Live About
label: a text yes its text beside its mark, as MudBlazor draws a checkbox's label
bind: the name of a state a state that holds whether it is ticked, both ways: true, false, or nil for neither with tri_state:
tri_state: true, false false a click goes from off to on, to neither (nil, a bar across the box) and back to off
required: any value true, or the error to show, such as "Name the formation": an empty value is an error, "Required" by default
validate: a lambda of one item, or its method name a lambda of its value answering the error to show, or nil while the value is fine, such as ->(name) { "Too short" if name.size < 3 }; a method name calls that method of the component
Event Tells
on_change true or false as the player ticked it, or nil for neither with tri_state:

Keys: confirm ticks it

Pad: A ticks it

Mouse: a click ticks it

Something went wrong. Reload

Connection interrupted

The site keeps trying to reconnect.

Reconnecting…

Could not reconnect. Trying again in seconds.

Could not reconnect. Retry now or reload the page.

The page was paused.

Could not continue. Retry now or reload the page.