telegram_webapp_sdk/webapp/theme.rs
1// SPDX-FileCopyrightText: 2025 RAprogramm <andrey.rozanov.vl@gmail.com>
2// SPDX-License-Identifier: MIT
3
4use wasm_bindgen::JsValue;
5
6use crate::webapp::TelegramWebApp;
7
8impl TelegramWebApp {
9 /// Call `WebApp.setHeaderColor(color)`.
10 ///
11 /// # Errors
12 /// Returns [`JsValue`] if the underlying JS call fails.
13 ///
14 /// # Examples
15 /// ```no_run
16 /// # use telegram_webapp_sdk::webapp::TelegramWebApp;
17 /// # let app = TelegramWebApp::instance().unwrap();
18 /// app.set_header_color("#ffffff").unwrap();
19 /// ```
20 pub fn set_header_color(&self, color: &str) -> Result<(), JsValue> {
21 self.call1("setHeaderColor", &color.into())
22 }
23
24 /// Call `WebApp.setBackgroundColor(color)`.
25 ///
26 /// # Errors
27 /// Returns [`JsValue`] if the underlying JS call fails.
28 ///
29 /// # Examples
30 /// ```no_run
31 /// # use telegram_webapp_sdk::webapp::TelegramWebApp;
32 /// # let app = TelegramWebApp::instance().unwrap();
33 /// app.set_background_color("#ffffff").unwrap();
34 /// ```
35 pub fn set_background_color(&self, color: &str) -> Result<(), JsValue> {
36 self.call1("setBackgroundColor", &color.into())
37 }
38
39 /// Call `WebApp.setBottomBarColor(color)`.
40 ///
41 /// # Errors
42 /// Returns [`JsValue`] if the underlying JS call fails.
43 ///
44 /// # Examples
45 /// ```no_run
46 /// # use telegram_webapp_sdk::webapp::TelegramWebApp;
47 /// # let app = TelegramWebApp::instance().unwrap();
48 /// app.set_bottom_bar_color("#ffffff").unwrap();
49 /// ```
50 pub fn set_bottom_bar_color(&self, color: &str) -> Result<(), JsValue> {
51 self.call1("setBottomBarColor", &color.into())
52 }
53}