MultipleDropdownComponent
A multi-select dropdown component.
You can add this component using SettingEx.addMultipleDropdown.
In order to add the styles for the component, use initPluginContext in your plugin’s onload() function.
Alternatively, you can copy styles from https://unpkg.com/@mnaoumov/obsidian-lib/dist/styles.css.
Import:
import { MultipleDropdownComponent } from '@mnaoumov/obsidian-lib/setting-components/multiple-dropdown-component';Signature:
export class MultipleDropdownComponent extends ValueComponent<readonly string[]> implements ValidatorComponent, ValueComponentWithChangeTracking<readonly string[]>Extends: ValueComponent<readonly string[]>
Implements: ValidatorComponent, ValueComponentWithChangeTracking<readonly string[]>
Constructor
new MultipleDropdownComponent(containerEl: HTMLElement)Creates a new multiple dropdown component.
Properties
| Property | Type | Description |
|---|---|---|
| dropdownComponent | DropdownComponent | The inner dropdown component. |
| onChange | (callback: (newValue: readonly string[]) => void) => this | Sets a callback function to be called when the value of the component changes. (Inherited from ValueComponentWithChangeTracking) |
| validatorEl | ValidatorElement | A validator element of the component. (Inherited from ValidatorComponent) |
Methods
| Method | Returns | Description |
|---|---|---|
| addOption(value, display) | this | Adds an option to the dropdown. |
| addOptions(options) | this | Adds multiple options to the dropdown. |
| getValue() | readonly string[] | Gets the value of the component. |
| onChange(callback) | this | Sets the callback function to be called when the component is changed. |
| setDisabled(isDisabled) | this | Sets the disabled state of the component. |
| setValue(value) | this | Sets the value of the component. |
| simulateChange__() | void | Simulate a change event. |
Links to this page: