Skip to content

SettingsButton

Implements Telegram Mini Apps Settings Button.

Initialization

Component constructor accepts visibility state, Telegram Mini Apps version and optional function to call Telegram Mini Apps methods.

typescript
import { SettingsButton, postEvent } from '@tma.js/sdk';

const settingsButton = new SettingsButton(false, '6.3', postEvent);
import { SettingsButton, postEvent } from '@tma.js/sdk';

const settingsButton = new SettingsButton(false, '6.3', postEvent);

Showing and hiding

To show and hide the SettingsButton, it is required to use show() and hide() methods. These methods update the button's isVisible property:

typescript
settingsButton.show();
console.log(settingsButton.isVisible); // true  

settingsButton.hide();
console.log(settingsButton.isVisible); // false
settingsButton.show();
console.log(settingsButton.isVisible); // true  

settingsButton.hide();
console.log(settingsButton.isVisible); // false

Events

List of events, which could be used in on and off component instance methods:

EventListenerTriggered when
click() => voidSettings Button was clicked
change() => voidSomething in component changed
change:isVisible(value: boolean) => voidisVisible property changed

Methods Support

List of methods, which could be used in supports component instance method:

  • show
  • hide
typescript
import { SettingsButton } from '@tma.js/sdk';

const settingsButton = new SettingsButton(...);
settingsButton.supports('show');
settingsButton.supports('hide');
import { SettingsButton } from '@tma.js/sdk';

const settingsButton = new SettingsButton(...);
settingsButton.supports('show');
settingsButton.supports('hide');

Released under the MIT License.