Skip to content

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

PropertyTypeDescription
inputElHTMLInputElementAn input element of the checkbox.
validatorElValidatorElementA validator element of the component.
(Inherited from ValidatorComponent)

Methods

MethodReturnsDescription
getValue()boolean | nullGets the value of the checkbox.
onChange(callback)thisSets the callback to be called when the checkbox is changed.
onChange(callback)thisSets a callback function to be called when the value of the component changes.
(Inherited from ValueComponentWithChangeTracking)
onChanged()voidCalled when the checkbox is changed.
setDisabled(disabled)thisSets the disabled state of the checkbox.
setValue(value)thisSets the value of the checkbox.

Links to this page: