Skip to content

ConfirmationButton

Official

A confirmation button used in a ConfirmationModal.

Import:

import { ConfirmationButton } from 'obsidian';

Signature:

export class ConfirmationButton extends ButtonComponent

Extends: ButtonComponent

Constructor

new ConfirmationButton(containerEl: HTMLElement, handleClose: () => void)

Creates a new instance of ConfirmationButton.

To get the constructor instance, use getConfirmationButtonConstructor from obsidian-typings/implementations.

Properties

PropertyTypeDescription
buttonElHTMLButtonElementThe HTML element representation of the button.
(Inherited from ButtonComponent)
disabledbooleanWhether the component is disabled.
(Inherited from ButtonComponent)

Methods

MethodReturnsDescription
clickCallback()voidThe function that's called after clicking the button.
(Inherited from ButtonComponent)
onClick(handler)thisSets the click event callback for the confirmation button. The modal is auto-closed after the click unless the handler returns a truthy value (or a promise that resolves to one).
onClick(callback)thisSets the click event callback for the button component.
(Inherited from ButtonComponent)
removeCta()thisRemoves the call to action style from the button component. CTA stands for call to action.
(Inherited from ButtonComponent)
removeDestructive()thisRemoves the destructive style from the button component.
(Inherited from ButtonComponent)
setButtonText(name)thisSets the text for the button component.
(Inherited from ButtonComponent)
setCancel()thisStyle the button as the dismissal action.
setClass(cls)thisSets the class for the button component.
(Inherited from ButtonComponent)
setCta()thisSets the button component to a call to action button. CTA stands for call to action. It changes how the button is styled, to make it stand out. Use it sparingly, to make the button stand out from others nearby.
(Inherited from ButtonComponent)
setDestructive()thisStyle the button as destructive (e.g. for actions that delete data or are otherwise hard to undo). Compose with setCta for a destructive primary action.
(Inherited from ButtonComponent)
setDisabled(disabled)thisSets the disabled state of the button component.
(Inherited from ButtonComponent)
setIcon(icon)thisSets the icon for the button component.
(Inherited from ButtonComponent)
setInitialFocus()thisMark this button as the focus target when the modal opens. If multiple buttons in the same modal have this set, the last-marked one wins.
setLoading(loading)thisToggles the button's loading state.
(Inherited from ButtonComponent)
setSecondary()thisPlace the button separately from the main button group (e.g. for a tertiary action that shouldn't sit next to the primary/cancel pair).
setTooltip(tooltip, options?)thisSets the tooltip for the button component.
(Inherited from ButtonComponent)
setWarning()thisSets the button component to a warning button. Usually it's added to buttons that perform destructive actions, such as deleting user's data.
(Inherited from ButtonComponent)
then(cb)thisFacilitates chaining.
(Inherited from ButtonComponent)

Links to this page: