Window Customization
Tauri provides lots of options for customizing the look and feel of your app’s window. You can create custom titlebars, have transparent windows, enforce size constraints, and more.
There are three ways to change the window configuration:
A common use of these window features is creating a custom titlebar. This short tutorial will guide you through that process.
Set decorations
to false
in your tauri.conf.json
:
Add window permissions in capability file.
By default, all plugin commands are blocked and cannot be accessed. You must define a list of permissions in your capabilities
configuration.
See Access Control List for more information.
Permission | Description |
---|---|
window:default | Default permissions for the plugin. Except window:allow-start-dragging . |
window:allow-close | Enables the close command without any pre-configured scope. |
window:allow-minimize | Enables the minimize command without any pre-configured scope. |
window:allow-start-dragging | Enables the start_dragging command without any pre-configured scope. |
window:allow-toggle-maximize | Enables the toggle_maximize command without any pre-configured scope. |
window:allow-internal-toggle-maximize | Enables the internal_toggle_maximize command without any pre-configured scope. |
Add this CSS sample to keep it at the top of the screen and style the buttons:
Put this at the top of your <body>
tag:
Note that you may need to move the rest of your content down so that the titlebar doesn’t cover it.
Use this code snippet to make the buttons work:
We are going to create the main window and change its background color from the Rust side.
Remove the main window from the tauri.conf.json
file:
Add cocoa
crate to dependencies so that we can use it to call the macOS native API:
Create the main window and change its background color:
© 2024 Tauri Contributors. CC-BY / MIT