com.vaadin.flow.component.checkbox.

Class CheckboxGroup<T>

All Implemented Interfaces:

AttachNotifier, DetachNotifier, HasAriaLabel, HasComponents, HasElement, HasEnabled, HasHelper, HasLabel, HasSize, HasStyle, HasTheme, HasValidation, HasValue<AbstractField.ComponentValueChangeEvent<CheckboxGroup<T>,Set<T>>,Set<T>>, HasValueAndElement<AbstractField.ComponentValueChangeEvent<CheckboxGroup<T>,Set<T>>,Set<T>>, HasClientValidation, HasThemeVariant<CheckboxGroupVariant>, HasTooltip, HasValidationProperties, InputField<AbstractField.ComponentValueChangeEvent<CheckboxGroup<T>,Set<T>>,Set<T>>, HasItemComponents<T>, HasValidator<Set<T>>, HasDataView<T,Void,CheckboxGroupDataView<T>>, HasListDataView<T,CheckboxGroupListDataView<T>>, MultiSelect<CheckboxGroup<T>,T>, Serializable

@Tag("vaadin-checkbox-group") @NpmPackage(value="@vaadin/polymer-legacy-adapter",version="24.7.0-alpha7") @NpmPackage(value="@vaadin/checkbox-group",version="24.7.0-alpha7") @JsModule("@vaadin/polymer-legacy-adapter/style-modules.js") @JsModule("@vaadin/checkbox-group/src/vaadin-checkbox-group.js") public class CheckboxGroup<T> extends AbstractSinglePropertyField<CheckboxGroup<T>,Set<T>> implements HasAriaLabel, HasClientValidation, HasDataView<T,Void,CheckboxGroupDataView<T>>, HasItemComponents<T>, InputField<AbstractField.ComponentValueChangeEvent<CheckboxGroup<T>,Set<T>>,Set<T>>, HasListDataView<T,CheckboxGroupListDataView<T>>, HasThemeVariant<CheckboxGroupVariant>, HasValidationProperties, HasValidator<Set<T>>, MultiSelect<CheckboxGroup<T>,T>

CheckBoxGroup is a multi-selection component where items are displayed as check boxes.

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

Validation

CheckboxGroup comes with a built-in validation mechanism that verifies that at least one checkbox is selected when required is enabled.

Validation is triggered whenever the user initiates a value change by toggling a checkbox. Programmatic value changes trigger validation as well. If validation fails, the component is marked as invalid and an error message is displayed below the group.

The required error message can be configured using either CheckboxGroup.CheckboxGroupI18n.setRequiredErrorMessage(String) or HasValidationProperties.setErrorMessage(String).

For more advanced validation that requires custom rules, you can use Binder. Please note that Binder provides its own API for the required validation, see asRequired().

However, if Binder doesn't fit your needs and you want to implement fully custom validation logic, you can disable the built-in validation by setting setManualValidation(boolean) to true. This will allow you to control the invalid state and the error message manually using HasValidationProperties.setInvalid(boolean) and HasValidationProperties.setErrorMessage(String) API.

Author:

Vaadin Ltd

See Also: