TriStateCheckboxComponent
A component that displays a tri-state checkbox.
You can add this component using SettingEx.addTriStateCheckbox.
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 { TriStateCheckboxComponent } from 'obsidian-dev-utils/obsidian/setting-components/tri-state-checkbox-component';Signature:
export class TriStateCheckboxComponent extends ValueComponent<boolean | null> implements ValidatorComponent, ValueComponentWithChangeTracking<boolean | null>Extends: ValueComponent<boolean | null>
Implements: ValidatorComponent, ValueComponentWithChangeTracking<boolean | null>
Constructor
new TriStateCheckboxComponent(containerEl: HTMLElement)Creates a new tri-state 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 | null | 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: