@tg-app/react
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

@tg-app/react

React components for Telegram Mini Apps.

Install

npm i -S @tg-app/react
# or
yarn add @tg-app/react

Usage

import { BackButton, MainButton, SettingsButton } from '@tg-app/react'

function App() {
  const [showBackButton, setShowBackButton] = useState(false)
  const [showMainButton, setShowMainButton] = useState(false)
  const [disableMainButton, setDisableMainButton] = useState(false)
  const [pendingMainButton, setPendingMainButton] = useState(false)
  const [mainButtonText, setMainButtonText] = useState('')

  const [mainButtonColor, setMainButtonColor] = useState(
    () => window.Telegram?.WebApp.themeParams.button_color,
  )

  const [mainButtonTextColor, setMainButtonTextColor] = useState(
    () => window.Telegram?.WebApp.themeParams.button_text_color,
  )

  const [showSettingsButton, setShowSettingsButton] = useState(false)

  return (
    <>
      <BackButton hide={!showBackButton} />

      <MainButton
        hide={!showMainButton}
        color={mainButtonColor}
        textColor={mainButtonTextColor}
        disabled={disableMainButton}
        pending={pendingMainButton}
      >
        {mainButtonText}
      </MainButton>

      <SettingsButton hide={!showSettingsButton} />
    </>
  )
}

Readme

Keywords

none

Package Sidebar

Install

npm i @tg-app/react

Weekly Downloads

1

Version

1.1.0

License

none

Unpacked Size

51.3 kB

Total Files

19

Last publish

Collaborators

  • bigslycat