Skip to content

Checkbox - Web Component

The Checkbox component can be used imported from:

Playground

Parameters

...

Events

This component has events. Check the documentation about how to use the events.

NamePayloadDescription
changebooleanReturns the new value of the "value" attribute
restartedvoidEmitted on value reset
blurvoidEmitted on blur

Slots

This component has slots. Check the documentation about how to use the slots.

NameTagsDescription
defaultspan
help-textspan

Parameters use

label

The z-checkbox component accepts a label attribute to set the text label of the component.

The slot label can also be used:

Checkbox label

model

Both value and checked parameters are used to set the value of the component.

name

The name attribute is used to set the name of the component. This is useful when the component is inside a form.

help-text

The help-text attribute will provide a text if a label is used:

We can also use the help-text slot:

This is a help textThis is a help text

Flags

indeterminate

The indeterminate attribute it's used to set the checkbox in an indeterminate state.

disabled

The attribute disabled will block the interaction with the component.

And with labels:

required

The attribute required will set the component as required.

invalid

The invalid attribute will set the component as invalid. If a label is present a default text will be shown unless is overwritten using help-text

Methods

reset()

We can all the reset() method of the WebComponent in order to reset the value. This will clean the internal states and emit the nullable value with the change event, plus a restarted event:

In this example, the button triggers the method:

Value:  false

Browser support

Detected engine:  

  • Chromium

  • Webkit

  • Gecko

HTML Examples

CodeSandbox example