You're viewing an older version of Vaadin JavaDoc. Please see version 24.7.0 for the latest.
com.vaadin.flow.component.checkbox.

Class Checkbox

All Implemented Interfaces:

AttachNotifier, BlurNotifier<Checkbox>, ClickNotifier<Checkbox>, DetachNotifier, Focusable<Checkbox>, FocusNotifier<Checkbox>, HasElement, HasEnabled, HasLabel, HasSize, HasStyle, HasValue<AbstractField.ComponentValueChangeEvent<Checkbox,Boolean>,Boolean>, HasValueAndElement<AbstractField.ComponentValueChangeEvent<Checkbox,Boolean>,Boolean>, HasTooltip, Serializable

@Tag("vaadin-checkbox") @NpmPackage(value="@vaadin/polymer-legacy-adapter",version="24.0.2") @NpmPackage(value="@vaadin/checkbox",version="24.0.2") @JsModule("@vaadin/polymer-legacy-adapter/style-modules.js") @JsModule("@vaadin/checkbox/src/vaadin-checkbox.js") public class Checkbox extends AbstractSinglePropertyField<Checkbox,Boolean> implements ClickNotifier<Checkbox>, Focusable<Checkbox>, HasLabel, HasSize, HasStyle, HasTooltip

Checkbox is an input field representing a binary choice.

Checkbox also has an indeterminate mode, see isIndeterminate() for more info.

Use CheckboxGroup to group related items. Individual checkboxes should be used for options that are not related to each other in any way.

Author:

Vaadin Ltd

See Also:

  • Constructor Details

  • Method Details

    • getLabel

      public String getLabel()

      Get the current label text.

      Specified by:

      getLabel in interface HasLabel

      Returns:

      the current label text

    • setLabel

      public void setLabel(String label)

      Set the current label text of this checkbox.

      Specified by:

      setLabel in interface HasLabel

      Parameters:

      label - the label text to set

    • setLabelComponent

      public void setLabelComponent(Component component)

      Replaces the label content with the given label component.

      Parameters:

      component - the component to be added to the label.

      Since:

      23.1

    • setAriaLabel

      public void setAriaLabel(String ariaLabel)

      Set the accessibility label of this checkbox.

      Parameters:

      ariaLabel - the accessibility label to set

      See Also:

    • setAutofocus

      public void setAutofocus(boolean autofocus)

      Set the checkbox to be input focused when the page loads.

      Parameters:

      autofocus - the boolean value to set

    • isAutofocus

      public boolean isAutofocus()

      Get the state for the auto-focus property of the checkbox.

      This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.

      Returns:

      the autofocus property from the checkbox

    • setIndeterminate

      public void setIndeterminate(boolean indeterminate)

      Set the indeterminate state of the checkbox.

      NOTE: As according to the HTML5 standard, this has only effect on the visual appearance, not on the checked value!

      Parameters:

      indeterminate - the boolean value to set

      See Also:

    • isIndeterminate

      @Synchronize(property="indeterminate", value="indeterminate-changed") public boolean isIndeterminate()

      Get the indeterminate state of the checkbox. The default value is false.

      An indeterminate checkbox is neither checked nor unchecked. A typical use case is a ?Select All? checkbox indicating that some, but not all, items are selected. When the user clicks an indeterminate checkbox, it is no longer indeterminate, and the checked value also changes.

      NOTE: As according to the HTML5 standard, this has only effect on the visual appearance, not on the checked value!

      Returns:

      the indeterminate property from the checkbox