React component for Telegram Web Apps (TWA) SecondaryButton.
npm i @twa-dev/sdk
TWA SDK contains an interface that controls BottomButton. It's written in imperative way:
const SecondaryButton = window.Telegram.WebApp.SecondaryButton;
SecondaryButton.setParams({ text: 'Cancel', position: 'bottom' });
SecondaryButton.show();
SecondaryButton.onClick(() => alert('cancelled'));
It's not the best way to write code, especially if you use libraries like React.
This package exports React component that wraps TWA SecondaryButton SDK:
import { MainButton, SecondaryButton } from '@twa-dev/sdk/react';
<MainButton text="Continue" onClick={() => alert('continue')} />
<SecondaryButton text="Cancel" position="bottom" onClick={() => alert('cancelled')} />
Naming is pretty straight forward and corresponds SDK props and methods:
text
color
textColor
disabled
progress
onClick
hasShineEffect
position