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

Property Type Description
buttonEl HTMLButtonElement The HTML element representation of the button.
(Inherited from ButtonComponent)
disabled boolean Whether the component is disabled.
(Inherited from ButtonComponent)

Methods

Method Returns Description
clickCallback() void The function that's called after clicking the button.
(Inherited from ButtonComponent)
onClick(handler) this Sets 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) this Sets the click event callback for the button component.
(Inherited from ButtonComponent)
removeCta() this Removes the call to action style from the button component. CTA stands for call to action.
(Inherited from ButtonComponent)
removeDestructive() this Removes the destructive style from the button component.
(Inherited from ButtonComponent)
setButtonText(name) this Sets the text for the button component.
(Inherited from ButtonComponent)
setCancel() this Style the button as the dismissal action.
setClass(cls) this Sets the class for the button component.
(Inherited from ButtonComponent)
setCta() this Sets 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() this Style 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) this Sets the disabled state of the button component.
(Inherited from ButtonComponent)
setIcon(icon) this Sets the icon for the button component.
(Inherited from ButtonComponent)
setInitialFocus() this Mark 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) this Toggles the button's loading state.
(Inherited from ButtonComponent)
setSecondary() this Place 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?) this Sets the tooltip for the button component.
(Inherited from ButtonComponent)
setWarning() this Sets 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) this Facilitates chaining.
(Inherited from ButtonComponent)

Links to this page: