Customizing Windows in Wails
Relevant Platforms: Windows macOS
Wails provides an API to control the appearance and functionality of the controls of a window. This functionality is available on Windows and macOS, but not on Linux.
Setting the Window Button States
The button states are defined by the ButtonState
enum:
ButtonEnabled
: The button is enabled and visible.ButtonDisabled
: The button is visible but disabled (grayed out).ButtonHidden
: The button is hidden from the titlebar.
The button states can be set during window creation or at runtime.
Setting Button States During Window Creation
When creating a new window, you can set the initial state of the buttons using
the WebviewWindowOptions
struct:
In the example above, the minimise button is hidden, the maximise button is inactive (grayed out), and the close button is active.
Setting Button States at Runtime
You can also change the button states at runtime using the following methods on
the Window
interface:
Platform Differences
The button state functionality behaves slightly differently on Windows and macOS:
Windows | Mac | |
---|---|---|
Disable Min/Max/Close | Disables Min/Max/Close | Disables Min/Max/Close |
Hide Min | Disables Min | Hides Min button |
Hide Max | Disables Max | Hides Max button |
Hide Close | Hides all controls | Hides Close |
Note: On Windows, it is not possible to hide the Min/Max buttons individually. However, disabling both will hide both of the controls and only show the close button.
Controlling Window Style (Windows)
To control the style of the titlebar on Windows, you can use the ExStyle
field
in the WebviewWindowOptions
struct:
Example:
Other options that affect the Extended Style of a window will be overridden by this setting:
- HiddenOnTaskbar
- AlwaysOnTop
- IgnoreMouseEvents
- BackgroundType