/telegram-skills:tg-miniapp-uifrom telegram-skills
Builds and debugs Telegram Mini App UIs: theme colors, dark mode, safe areas, viewport height, keyboard handling, MainButton/SecondaryButton, BackButton, haptic feedback, and cross-client layout bugs.
Ships in telegram-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Checked against the official docs on 2026-10-30: Bot API 10.3 (August 24, 2026), Mini Apps page, telegram-web-app.js?64. The Bot API 10.4 and 10.5 changelogs change nothing here (checked 2026-12-02).
No client or device was used to write this skill. API facts come from the docs; bug reports come from public trackers. Acceptance on a real iPhone and Android device is still ahead: run the check below. A browser emulator doesn't catch these bugs.
Client bugs with platform, client, issue number and date: client-pitfalls.md. Read it before you blame your own CSS.
Put telegram-web-app.js in <head> before other scripts. Call Telegram.WebApp.ready() as soon as the essential interface is loaded: it hides the loading placeholder. expand() asks for the maximum height; isExpanded reports it.
Color everything from the theme and repaint on change. There is no separate dark mode API: colorScheme is light or dark, and the palette follows it.
body {
background: var(--tg-theme-bg-color);
color: var(--tg-theme-text-color);
}
.hint { color: var(--tg-theme-hint-color); }
.card { background: var(--tg-theme-section-bg-color, var(--tg-theme-secondary-bg-color)); }
themeParams fields map to --tg-theme-* variables, and every field is optional. Give each a fallback. Fields by version: secondary_bg_color 6.1; header, accent, section, subtitle and destructive colors 7.0; section_separator_color 7.6; bottom_bar_bg_color 7.10.themeChanged for logic that reads colors in JS; the CSS variables update on their own.setHeaderColor, setBackgroundColor and setBottomBarColor take #RRGGBB or keywords. Prefer setHeaderColor('bg_color'): a hex header produces light glass buttons on iOS, see pitfalls.viewportHeight / --tg-viewport-height changes during gestures and animations, and its refresh rate is too low to follow the bottom edge.viewportStableHeight / --tg-viewport-stable-height updates after the app settles. Pin bottom elements to this one.viewportChanged passes isStateStable; run layout work when it is true.hideKeyboard() (9.1) closes the on-screen keyboard.Two sets of insets, and fullscreen needs both:
| Set | Covers | CSS variables |
|---|---|---|
safeAreaInset | Notches and system navigation | --tg-safe-area-inset-{top,bottom,left,right} |
contentSafeAreaInset | Telegram's own controls | --tg-content-safe-area-inset-{top,bottom,left,right} |
.screen {
padding-top: calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
padding-bottom: var(--tg-safe-area-inset-bottom, 0px);
}
Read JS values in safeAreaChanged and contentSafeAreaChanged handlers. These events and fullscreenChanged arrive separately, so inset values read inside fullscreenChanged can be stale (tma.js #704, maintainer reply, 2025-04-03).
requestFullscreen() (8.0) reports through fullscreenChanged, and failure through fullscreenFailed with UNSUPPORTED or ALREADY_FULLSCREEN. No list of supporting clients is published, and a practitioner report describes iOS 12.9 sending neither event. So handle the events and also check isFullscreen on a timer. The timeout below is a choice, not a documented value.
function enterFullscreen(onResult) {
const app = Telegram.WebApp;
if (!app.isVersionAtLeast('8.0')) return onResult(false, 'OLD_CLIENT');
let timer;
const finish = (ok, reason) => {
clearTimeout(timer);
app.offEvent('fullscreenChanged', changed);
app.offEvent('fullscreenFailed', failed);
onResult(ok, reason);
};
const changed = () => finish(app.isFullscreen, 'CHANGED');
const failed = ({ error }) => finish(error === 'ALREADY_FULLSCREEN', error);
app.onEvent('fullscreenChanged', changed);
app.onEvent('fullscreenFailed', failed);
timer = setTimeout(() => finish(app.isFullscreen, 'NO_EVENT'), 1500);
app.requestFullscreen();
}
Design the layout to work without fullscreen. Set setHeaderColor even in fullscreen, where the header is transparent: the color picks a contrasting status bar and controls. lockOrientation() keeps the current orientation (8.0).
Use MainButton and SecondaryButton instead of drawing your own bottom bar.
const { MainButton, SecondaryButton } = Telegram.WebApp;
MainButton.setParams({ text: 'Pay', is_visible: true, has_shine_effect: true });
SecondaryButton.setParams({ text: 'Cancel', is_visible: true, position: 'left' });
MainButton.onClick(async () => {
MainButton.showProgress(); // disabled while running; showProgress(true) leaves it active
try { await submit(); } finally { MainButton.hideProgress(); }
});
SecondaryButton exists since 7.10. position is left (default), right, top or bottom, and applies only when both buttons are visible.setParams also takes color, text_color, is_active, and icon_custom_emoji_id (9.5).onClick adds a handler, so a re-render adds another. Remove the old one with offClick.BackButton lives in the header: show(), hide(), onClick(). Wire it to your router, and hide it on the root screen.
disableVerticalSwipes() (7.7) only when swipes conflict with your own gestures; the docs recommend keeping them on. Users can still close by swiping the header.enableClosingConfirmation() (6.2) when closing would lose user input.HapticFeedback (6.1):
| Moment | Call |
|---|---|
| Tap or collision | impactOccurred('light' | 'medium' | 'heavy' | 'rigid' | 'soft') |
| Action result | notificationOccurred('success' | 'error' | 'warning') |
| Selection moved to another item | selectionChanged(); skip it when the user makes or confirms a choice |
The docs ask for smooth animation, ideally 60 fps. On Android the User-Agent ends with a performance class; cut animations and effects on LOW. iOS has no equivalent.
const match = navigator.userAgent.match(/Telegram-Android\/.*;\s*(LOW|AVERAGE|HIGH)\)/);
const isLowEnd = match?.[1] === 'LOW';
Responsive and mobile-first; interactive elements that mimic native ones; labels on all inputs and images; theme colors tracked live; safe area and content safe area respected. The page gives no spacing numbers or components.
Run on a real iPhone and a real Android phone, light and dark theme. The check is done when lines 1–5 have passed on both and line 6 on a low-end Android phone.
telegram-web-app.js: https://telegram.org/js/telegram-web-app.js?64What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub serejaris/telegram-skills --plugin telegram-skills15 skills in this plugin
/tg-bot-opsUse when running a Telegram bot in production: webhook or long polling, allowed_updates, webhook secret token, bot settings from code (setMySettings, getMe, privacy mode, callback_query_mode), botinvite links, 429 and retry_after, file retries, broadcast limits and paid broadcasts, lost updates on shutdown, a poison update after new Bot API types, t.me outage and fallback domains, local Bot API server./tg-capability-mapUse before promising a Telegram feature or designing around one: what a bot can do in Bot API, what lives only in the client or MTProto (scheduled posts, channel stats, poll stats, channel stories, folders, boosts, welcome messages, communities), and what never to promise from a bot./tg-classic-messagesUse when sending or editing ordinary Telegram bot messages: sendMessage text, MarkdownV2/HTML escaping and entities, quotes, date_time, custom emoji, link previews, photos and documents with captions, albums, upload size limits, protect_content, copy, forward, delete. Also use to choose between a classic message and a rich message./tg-markdown-to-richUse when converting an existing Markdown file or stdin into a Telegram Rich Message (InputRichMessage.markdown) for sendRichMessage, including file_id, URL, and multipart upload media bindings. Triggers: "send markdown to Telegram", "convert doc to rich message", "telegram rich message from file"./tg-miniapp-launch-authUse when choosing how a Telegram Mini App opens (keyboard, inline or menu button, main app, direct link, startapp, join request) or when a server must trust a Mini App user: validating initData by HMAC or Ed25519, signature in the check string, auth_date, isVersionAtLeast gating, origin protection, test launch links in the test environment./tg-operator-cardsUse when turning the facts of one bot event — a payment, an order, an enrollment, a moderation decision — into a card for the person who runs the bot, in an admin chat or a private chat with the owner: a review card awaiting a decision or a receipt, read in two seconds on a phone.Other plugins' skills for the same job