C.W.K.
Stream
Lesson 02 of 06 · published

Window Config & Labels

~11 min · tauri, windows, labels, config

Level 0Web Tourist
0 XP0/56 lessons0/13 achievements
0/100 XP to next level100 XP to go0% complete
"A label is a window's name that never changes. The title is a costume it can swap any time."

Static Windows in Config

The app.windows array in tauri.conf.json declares windows that exist from launch. Each entry sets the initial title, size, and behavior — and critically, a label. The default scaffold gives you one window labeled main. You can add more (a splash, a persistent toolbar) right here, no Rust needed, and they'll open with the app.

Label = Identity, Title = Display

Don't confuse the two. The label is a stable, unique string id — main, settings, splash — that never changes and is how every API refers to the window: get_webview_window("settings"), emit_to("settings", …). The title is the human text in the title bar; it can change at runtime and isn't unique. Identify windows by label, always. Targeting by title is a bug waiting to happen.

Config vs Code: When to Use Which

Use config for windows that always exist (your main window). Use runtime creation for windows that depend on user action or data (a document window per open file, a settings window only when requested). A common pattern: declare main in config, create everything else in Rust. You can even declare a window in config but start it hidden, then show() it when ready — handy for a splash-then-main sequence.

Code

Declaring windows (and labels) in config·json
// tauri.conf.json — two windows declared statically, each with a label.
{
  "app": {
    "windows": [
      { "label": "main", "title": "My App", "width": 1100, "height": 720 },
      { "label": "splash", "url": "splash.html", "width": 400, "height": 300,
        "decorations": false, "visible": true }
    ]
  }
}
Labels are how you reach windows in code·rust
use tauri::Manager;

// Find any window by its label — from setup, a command, anywhere.
fn close_splash_show_main(app: &tauri::AppHandle) {
    if let Some(splash) = app.get_webview_window("splash") {
        let _ = splash.close();
    }
    if let Some(main) = app.get_webview_window("main") {
        let _ = main.show();
        let _ = main.set_focus();
    }
}

External links

Exercise

Give your main window an explicit label in tauri.conf.json (if it doesn't have one), then write a command that toggles the window's title at runtime while keeping the label fixed. Confirm the title changes but get_webview_window(label) still finds it. You've felt the label/title split firsthand.
Hint
win.set_title("new title") changes the display; the label you pass to get_webview_window never changes. That separation is the whole point — identity vs presentation.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.