# Usage
## Register the plugin
Default settings:
```rust
tauri::Builder::default()
.plugin(tauri_plugin_decor::init())
.run(tauri::generate_context!())
.unwrap();
```
Configured:
```rust
use tauri_plugin_decor::DecorPluginBuilder;
let plugin = DecorPluginBuilder::new()
.controls_height(36.0)
.controls_scale(1.1)
.controls_close_hover_bg("rgba(220,40,40,1)")
.build();
tauri::Builder::default().plugin(plugin)/* … */;
```
## Opt windows in
Either globally:
```rust
DecorPluginBuilder::new().controls_auto_titlebar(true).build();
```
…or per window from `setup`:
```rust
use tauri::Manager;
use tauri_plugin_decor::WebviewWindowExt;
win.create_overlay_titlebar()?;
Ok(())
})
```
## Capabilities
Add to your capability file:
```json
{
"permissions": [
"core:default",
"core:window:allow-start-dragging",
"core:window:allow-close",
"core:window:allow-minimize",
"core:window:allow-maximize",
"core:window:allow-unmaximize",
"decor:allow-show-snap-overlay",
"decor:allow-update-style"
]
}
```
On macOS the window must be configured with `titleBarStyle: "Overlay"` and
`hiddenTitle: true`.
## Drag region
Tauri only drags from elements that opt in:
```html
<header data-tauri-drag-region>Drag me</header>
```
## Setters
All `controls_*` calls compile on every platform. The table shows what they
actually do.
| `controls_height(f64)` | traffic-light inset Y | base titlebar height (px) | base titlebar height (px) |
| `controls_inset_x(f64)` | traffic-light inset X | — | — |
| `controls_spacing(f64)` | gap between buttons | — | — |
| `controls_scale(f64)` | `CALayer` transform | multiplier on base height + width | multiplier on base height + width |
| `controls_button_width(u32)` | — | base per-button caption width | base per-button caption width |
| `controls_close_hover_bg(&str)` | — | CSS color for close hover | CSS color for close hover |
| `controls_button_hover_bg(&str)` | — | CSS color for min/max hover | CSS color for min/max hover |
| `controls_auto_titlebar(bool)` | — | inject overlay on every window | inject overlay on every window |
On Windows and Linux the rendered titlebar height is `controls_height × controls_scale`
and the rendered button width is `controls_button_width × controls_scale`. Both
inputs are stored separately, so calling `set_controls_scale` is idempotent and
order-independent — it never compounds with previous calls.
Windows-only: `snap_overlay_delay_ms(u64)` adjusts the post-press delay used
by `show_snap_overlay`.
## Runtime updates
Change values on already-shown windows.
From Rust:
```rust
use tauri::Manager;
use tauri_plugin_decor::{DecorExt, DecorStyle};
let decor = app.decor();
decor.set_controls_scale(1.3);
decor.set_controls_close_hover_bg("rgba(220,40,40,1)");
decor.reconfigure(DecorStyle {
controls_height: Some(44.0),
controls_button_width: Some(54),
..Default::default()
});
```
From the frontend:
```ts
import { invoke } from "@tauri-apps/api/core";
});
```