Skip to content

BackButton

Implements Telegram Mini Apps Back Button.

Initialization

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

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

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

const backButton = new BackButton(false, '6.3', postEvent);

Showing and hiding

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

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

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

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

Events

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

EventListenerTriggered when
click() => voidBack 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 { BackButton } from '@tma.js/sdk';

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

const backButton = new BackButton(...);
backButton.supports('show');
backButton.supports('hide');

Released under the MIT License.