Skip to content

addSingleChoiceMenuItems<T>

Adds a group of menu items of which exactly one is checked, like radio buttons.

A click checks the clicked item and unchecks the rest of the group before calling onChange, so a menu that is shown again shows the new choice. Obsidian still closes the menu after a click (read from its 1.15.0 MenuItem.handleEvent). Values are compared with ===.

Import:

import { addSingleChoiceMenuItems } from '@mnaoumov/obsidian-lib/menu';

Signature:

function addSingleChoiceMenuItems(params: AddSingleChoiceMenuItemsParams<T>): MenuItem[]

Parameters:

Parameter Type Description
params AddSingleChoiceMenuItemsParams<T> The parameters.

Returns: MenuItem[] — The items added, in option order.


Links to this page: