CheckboxComponent
A component that displays a checkbox.
You can add this component using SettingEx.addCheckbox.
In order to add the styles for the component, use initPluginContext in your plugin’s onload() function.
Alternatively, you can copy styles from https://github.com/mnaoumov/obsidian-dev-utils/releases/latest/download/styles.css.
Import:
import { CheckboxComponent } from 'obsidian-dev-utils/obsidian/setting-components/checkbox-component';Signature:
export class CheckboxComponent extends ValueComponent<boolean> implements ValidatorComponent, ValueComponentWithChangeTracking<boolean>Extends: ValueComponent<boolean>
Implements: ValidatorComponent, ValueComponentWithChangeTracking<boolean>
Constructor
new CheckboxComponent(containerEl: HTMLElement)Creates a new checkbox component.
Properties
| Property | Type | Description |
|---|---|---|
| inputEl | HTMLInputElement | An input element of the checkbox. |
| validatorEl | ValidatorElement | A validator element of the component. (Inherited from ValidatorComponent) |
Methods
| Method | Returns | Description |
|---|---|---|
| getValue() | boolean | Gets the value of the checkbox. |
| onChange(callback) | this | Sets the callback to be called when the checkbox is changed. |
| onChange(callback) | this | Sets a callback function to be called when the value of the component changes. (Inherited from ValueComponentWithChangeTracking) |
| onChanged() | void | Called when the checkbox is changed. |
| setDisabled(disabled) | this | Sets the disabled state of the checkbox. |
| setValue(value) | this | Sets the value of the checkbox. |
Links to this page: