---
sidebar_position: 3
---

# オプション

## Application Options

The `Options.App` struct contains the application configuration. It is passed to the `wails.Run()` method:

```go title="Example"
import "github.com/wailsapp/wails/v2/pkg/options"

func main() {

    err := wails.Run(&options.App{
        Title:              "Menus Demo",
        Width:              800,
        Height:             600,
        DisableResize:      false,
        Fullscreen:         false,
        Frameless:          true,
        MinWidth:           400,
        MinHeight:          400,
        MaxWidth:           1280,
        MaxHeight:          1024,
        StartHidden:        false,
        HideWindowOnClose:  false,
        BackgroundColour:   &options.RGBA{R: 0, G: 0, B: 0, A: 255},
        AlwaysOnTop:        false,
        Assets:             assets,
        AssetsHandler:      assetsHandler,
        Menu:               app.applicationMenu(),
        Logger:             nil,
        LogLevel:           logger.DEBUG,
        LogLevelProduction: logger.ERROR,
        OnStartup:          app.startup,
        OnDomReady:         app.domready,
        OnShutdown:         app.shutdown,
        OnBeforeClose:      app.beforeClose,
        WindowStartState:   options.Maximised,
        CSSDragProperty:   "--wails-draggable",
        CSSDragValue:      "drag",
        Bind: []interface{}{
            app,
        },
        Windows: &windows.Options{
            WebviewIsTransparent:              false,
            WindowIsTranslucent:               false,
            BackdropType:                      windows.Mica,
            DisableWindowIcon:                 false,
            DisableFramelessWindowDecorations: false,
            WebviewUserDataPath:               "",
            WebviewBrowserPath:                "",
            Theme:                             windows.SystemDefault,
            CustomTheme: &windows.ThemeSettings{
                DarkModeTitleBar:   windows.RGB(20, 20, 20),
                DarkModeTitleText:  windows.RGB(200, 200, 200),
                DarkModeBorder:     windows.RGB(20, 0, 20),
                LightModeTitleBar:  windows.RGB(200, 200, 200),
                LightModeTitleText: windows.RGB(20, 20, 20),
                LightModeBorder:    windows.RGB(200, 200, 200),
            },
            // User messages that can be customised
            Messages *windows.Messages
            // OnSuspend is called when Windows enters low power mode
            OnSuspend func()
            // OnResume is called when Windows resumes from low power mode
            OnResume func()
        },
        Mac: &mac.Options{
            TitleBar: &mac.TitleBar{
                TitlebarAppearsTransparent: true,
                HideTitle:                  false,
                HideTitleBar:               false,
                FullSizeContent:            false,
                UseToolbar:                 false,
                HideToolbarSeparator:       true,
            },
            Appearance:           mac.NSAppearanceNameDarkAqua,
            WebviewIsTransparent: true,
            WindowIsTranslucent:  false,
            About: &mac.AboutInfo{
                Title:   "My Application",
                Message: "© 2021 Me",
                Icon:    icon,
            },
        },
        Linux: &linux.Options{
            Icon: icon,
            WindowIsTranslucent: false,
        },
    })
    if err != nil {
        log.Fatal(err)
    }
}

```

### Title

The text shown in the window's title bar.

名前: Title<br/> データ型: `string`

### Width

The initial width of the window.

名前: Width<br/> データ型: `int`<br/> デフォルト値: 1024

### Height

The initial height of the window.

名前: Height<br/> データ型: `int`<br/> デフォルト値: 768

### DisableResize

By default, the main window is resizable. Setting this to `true` will keep it a fixed size.

名前: DisableResize<br/> データ型: `bool`

### Fullscreen

Setting this to `true` will make the window fullscreen at startup.

名前: Fullscreen<br/> データ型: `bool`

### Frameless

When set to `true`, the window will have no borders or title bar. Also see [Frameless Windows](../guides/frameless.mdx).

名前: Frameless<br/> データ型: `bool`

### MinWidth

This sets the minimum width for the window. If the value given in `Width` is less than this value, the window will be set to `MinWidth` by default.

名前: MinWidth<br/> データ型: `int`

### MinHeight

This sets the minimum height for the window. If the value given in `Height` is less than this value, the window will be set to `MinHeight` by default.

名前: MinHeight<br/> データ型: `int`

### MaxWidth

This sets the maximum width for the window. If the value given in `Width` is more than this value, the window will be set to `MaxWidth` by default.

名前: MaxWidth<br/> データ型: `int`

### MaxHeight

This sets the maximum height for the window. If the value given in `Height` is more than this value, the window will be set to `MaxHeight` by default.

名前: MaxHeight<br/> データ型: `int`

### StartHidden

When set to `true`, the application will be hidden until [WindowShow](../reference/runtime/window.mdx#windowshow) is called.

名前: StartHidden<br/> データ型: `bool`

### HideWindowOnClose

By default, closing the window will close the application. この設定を`true`にすると、ウィンドウを閉じる操作をした際に、

ウィンドウが非表示の状態になります。

名前: HideWindowOnClose<br/> データ型: `bool`

### BackgroundColour

This value is the default background colour of the window. 例: options.NewRGBA(255,0,0,128) - 50%透過された赤色

名前: BackgroundColour<br/> データ型: `*options.RGBA`<br/> デフォルト値: white

### AlwaysOnTop

Indicates that the window should stay above other windows when losing focus.

名前: AlwaysOnTop<br/> データ型: `bool`

### Assets

The frontend assets to be used by the application. Requires an `index.html` file.

名前: Assets<br/> データ型: `embed.FS`

### AssetsHandler

<img src="http://badges.github.io/stability-badges/dist/experimental.svg" />

The assets handler is a generic `http.Handler` which will be called for any non GET request on the assets server and for GET requests which can not be served from the `assets` because the file is not found.

| 値                       | Win | Mac | Lin |
| ----------------------- | --- | --- | --- |
| GET                     | ✅   | ✅   | ✅   |
| POST                    | ✅   | ✅   | ❌   |
| PUT                     | ✅   | ✅   | ❌   |
| PATCH                   | ✅   | ✅   | ❌   |
| DELETE                  | ✅   | ✅   | ❌   |
| Request Headers         | ✅   | ✅   | ❌   |
| Request Body            | ✅   | ✅   | ❌   |
| Request Body Streaming  | ❌   | ❌   | ❌   |
| Response StatusCodes    | ✅   | ✅   | ❌   |
| Response Headers        | ✅   | ✅   | ❌   |
| Response Body           | ✅   | ✅   | ✅   |
| Response Body Streaming | ❌   | ❌   | ✅   |

NOTE: Linux is currently very limited due to targeting a WebKit2GTK Version < 2.36.0. In the future some features will be supported by the introduction of WebKit2GTK 2.36.0+ support.

NOTE: When used in combination with a Frontend DevServer there might be limitations, eg. Vite serves the index.html on every path, that does not contain a file extension.

名前: AssetsHandler<br/> データ型: `http.Handler`

### Menu

The menu to be used by the application. More details about Menus in the [Menu Reference](../reference/runtime/menu.mdx).

:::note


Macでは、メニューが指定されていない場合、デフォルトメニューが作成されます。

:::


名前: Menu<br/> データ型: `*menu.Menu`

### Logger

The logger to be used by the application. More details about logging in the [Log Reference](../reference/runtime/log.mdx).

名前: Logger<br/> データ型: `logger.Logger`<br/> デフォルト値: 標準出力へのロガー

### LogLevel

The default log level. More details about logging in the [Log Reference](../reference/runtime/log.mdx).

名前: LogLevel<br/> データ型: `logger.LogLevel`<br/> デフォルト値: 開発モードの場合は`Info`、本番モードの場合は`Error`

### LogLevelProduction

The default log level for production builds. More details about logging in the [Log Reference](../reference/runtime/log.mdx).

名前: LogLevelProduction<br/> データ型: `logger.LogLevel`<br/> デフォルト値: `Error`

### OnStartup

This callback is called after the frontend has been created, but before `index.html` has been loaded. It is given the application context.

名前: OnStartup<br/> データ型: `func(ctx context.Context)`

### OnDomReady

This callback is called after the frontend has loaded `index.html` and its resources. It is given the application context.

名前: OnDomReady<br/> データ型: `func(ctx context.Context)`

### OnShutdown

This callback is called after the frontend has been destroyed, just before the application terminates. It is given the application context.

名前: OnShutdown<br/> データ型: `func(ctx context.Context)`

### OnBeforeClose

If this callback is set, it will be called when the application is about to quit, either by clicking the window close button or calling `runtime.Quit`. Returning true will cause the application to continue, false will continue shutdown as normal. This is good for confirming with the user that they wish to exit the program.

Example:

```go title=windowsapp.go
func (b *App) beforeClose(ctx context.Context) (prevent bool) {
    dialog, err := runtime.MessageDialog(ctx, runtime.MessageDialogOptions{
        Type:          runtime.QuestionDialog,
        Title:         "Quit?",
        Message:       "Are you sure you want to quit?",
    })

    if err != nil {
        return false
    }
    return dialog != "Yes"
}
```

名前: OnBeforeClose<br/> データ型: `func(ctx context.Context) bool`

### WindowStartState

Defines how the window should present itself at startup.

| 値          | Win | Mac | Lin |
| ---------- | --- | --- | --- |
| Fullscreen | ✅   | ✅   | ✅   |
| Maximised  | ✅   | ✅   | ✅   |
| Minimised  | ✅   | ❌   | ✅   |

名前: WindowStartState<br/> データ型: `options.WindowStartState`

### CSSDragProperty

ウィンドウをドラッグできる要素を特定するためのCSSプロパティ名を設定します。 デフォルト値: `--wails-draggable`

名前: CSSDragProperty<br/> データ型: `string`

### CSSDragValue

Indicates what value the `CSSDragProperty` style should have to drag the window. デフォルト値: `drag`

名前: CSSDragValue<br/> データ型: `string`

### Bind

A slice of struct instances defining methods that need to be bound to the frontend.

名前: Bind<br/> データ型: `[]interface{}`

### Windows

[Windows固有のオプション](#windows)を定義します。

名前: Windows<br/> データ型: `*windows.Options`

#### WebviewIsTransparent

Setting this to `true` will make the webview background transparent when an alpha value of `0` is used. This means that if you use `rgba(0,0,0,0)` for `background-color` in your CSS, the host window will show through. Often combined with [WindowIsTranslucent](#WindowIsTranslucent) to make frosty-looking applications.

名前: WebviewIsTransparent<br/> データ型: `bool`

#### WindowIsTranslucent

Setting this to `true` will make the window background translucent. 多くの場合、[WebviewIsTransparent](#WebviewIsTransparent)と組み合わせて使用されます。

ビルド22621より前のWindows 11の場合、半透明を実現させるために[BlurBehind](https://learn.microsoft.com/ja-jp/windows/win32/dwm/blur-ovw)メソッドを使用するため、処理が遅くなる可能性があります。 ビルド22621以降のWindows 11では、より高速な、新しい半透明タイプが有効になります。 デフォルトで使用される半透明タイプは、Windowsにより決定されます。 このタイプを設定するには、[BackdropType](#BackdropType)オプションを使用してください。

名前: WindowIsTranslucent<br/> データ型: `bool`

#### BackdropType

:::note


この設定を適用するには、Windows 11 ビルド22621以降が必要です。

:::


ウィンドウの半透明タイプを設定します。 この設定は、[WindowIsTranslucent](#WindowIsTranslucent)が`true`に設定されている場合にのみ適用されます。

名前: BackdropType<br/> データ型: `windows.BackdropType`

値は次のいずれかを指定してください:

| 値       | Description                                                                         |
| ------- | ----------------------------------------------------------------------------------- |
| Auto    | Windowsに背景を決定させる                                                                    |
| None    | 半透明にしない                                                                             |
| Acrylic | [アクリル](https://learn.microsoft.com/ja-jp/windows/apps/design/style/acrylic)の効果を使用する |
| Mica    | [マイカ](https://learn.microsoft.com/ja-jp/windows/apps/design/style/mica)の効果を使用する     |
| Tabbed  | タブを使用する。 これはマイカに似ている背景です。                                                           |

#### DisableWindowIcon

Setting this to `true` will remove the icon in the top left corner of the title bar.

名前: DisableWindowIcon<br/> データ型: `bool`

#### DisableFramelessWindowDecorations

Setting this to `true` will remove the window decorations in [Frameless](#Frameless) mode. This means there will be no 'Aero Shadow' and no 'Rounded Corners' shown for the window. Please note that 'Rounded Corners' are only supported on Windows 11.

名前: DisableFramelessWindowDecorations<br/> データ型: `bool`

#### WebviewUserDataPath

This defines the path where the WebView2 stores the user data. If empty `%APPDATA%\[BinaryName.exe]` will be used.

名前: WebviewUserDataPath<br/> データ型: `string`

#### WebviewBrowserPath

This defines the path to a directory with WebView2 executable files and libraries. If empty, webview2 installed in the system will be used.

Important information about distribution of fixed version runtime:

- [How to get and extract runtime](https://docs.microsoft.com/en-us/microsoft-edge/webview2/concepts/distribution#details-about-the-fixed-version-runtime-distribution-mode)
- [Known issues for fixed version](https://docs.microsoft.com/en-us/microsoft-edge/webview2/concepts/distribution#known-issues-for-fixed-version)
- [The path of fixed version of the WebView2 Runtime should not contain \Edge\Application\.](https://docs.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.1245.22#createcorewebview2environmentwithoptions)

名前: WebviewBrowserPath<br/> データ型: `string`

#### Theme

Minimum Windows Version: Windows 10 2004/20H1

This defines the theme that the application should use:

| 値             | Description                                                                                                                                    |
| ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| SystemDefault | _デフォルト値_です。 The theme will be based on the system default. If the user changes their theme, the application will update to use the new setting |
| Dark          | The application will use a dark theme exclusively                                                                                              |
| Light         | The application will use a light theme exclusively                                                                                             |

名前: Theme<br/> データ型: `windows.Theme`

#### CustomTheme

:::note


サポートされるWindowsの最小バージョン: Windows 10/11 2009/21H2 ビルド22000

:::


Allows you to specify custom colours for TitleBar, TitleText and Border for both light and dark mode, as well as when the window is active or inactive.

名前: CustomTheme<br/> データ型: `windows.CustomTheme`

##### CustomTheme 型

The CustomTheme struct uses `int32` to specify the colour values. These are in the standard(!) Windows format of: `0x00BBGGAA`. A helper function is provided to do RGB conversions into this format: `windows.RGB(r,g,b uint8)`.

NOTE: Any value not provided will default to black.

```go
type ThemeSettings struct {
    DarkModeTitleBar           int32
    DarkModeTitleBarInactive   int32
    DarkModeTitleText          int32
    DarkModeTitleTextInactive  int32
    DarkModeBorder             int32
    DarkModeBorderInactive     int32
    LightModeTitleBar          int32
    LightModeTitleBarInactive  int32
    LightModeTitleText         int32
    LightModeTitleTextInactive int32
    LightModeBorder            int32
    LightModeBorderInactive    int32
}
```

Example:

```go
    CustomTheme: &windows.ThemeSettings{
        // Theme to use when window is active
        DarkModeTitleBar:   windows.RGB(255, 0, 0),   // Red
        DarkModeTitleText:  windows.RGB(0, 255, 0),   // Green
        DarkModeBorder:     windows.RGB(0, 0, 255),   // Blue
        LightModeTitleBar:  windows.RGB(200, 200, 200),
        LightModeTitleText: windows.RGB(20, 20, 20),
        LightModeBorder:    windows.RGB(200, 200, 200),
        // Theme to use when window is inactive
        DarkModeTitleBarInactive:   windows.RGB(128, 0, 0),
        DarkModeTitleTextInactive:  windows.RGB(0, 128, 0),
        DarkModeBorderInactive:     windows.RGB(0, 0, 128),
        LightModeTitleBarInactive:  windows.RGB(100, 100, 100),
        LightModeTitleTextInactive: windows.RGB(10, 10, 10),
        LightModeBorderInactive:    windows.RGB(100, 100, 100),
    },
```

#### Messages

A struct of strings used by the webview2 installer if a valid webview2 runtime is not found.

名前: Messages<br/> データ型: `*windows.Messages`

Customise this for any language you choose to support.

#### ResizeDebounceMS

ResizeDebounceMS is the amount of time to debounce redraws of webview2 when resizing the window. The default value (0) will perform redraws as fast as it can.

名前: ResizeDebounceMS<br/> データ型: `uint16`

#### OnSuspend

Windowsがローパワーモード(サスペンド/休止状態) に切り替わると呼び出されるコールバックを設定します。

名前: OnSuspend<br/> データ型: `func()`

#### OnResume

Windowsがローパワーモード(サスペンド/休止状態) から復帰したときに呼び出されるコールバックを設定します。

名前: OnResume<br/> データ型: `func()`

### Mac

[Mac固有のオプション](#mac)を定義します。

名前: Mac<br/> データ定義: `*mac.Options`

#### TitleBar

The TitleBar struct provides the ability to configure the look and feel of the title bar.

名前: TitleBar<br/> データ型: [`*mac.TitleBar`](#titlebar-struct)

##### Titlebar struct

The titlebar of the application can be customised by using the TitleBar options:

```go
type TitleBar struct {
    TitlebarAppearsTransparent bool
    HideTitle                  bool
    HideTitleBar               bool
    FullSizeContent            bool
    UseToolbar                 bool
    HideToolbarSeparator       bool
}
```

| Name                       | Description                                                                                                                                                                                                                          |
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| TitlebarAppearsTransparent | Makes the titlebar transparent. This has the effect of hiding the titlebar and the content fill the window. [Apple Docs](https://developer.apple.com/documentation/appkit/nswindow/1419167-titlebarappearstransparent?language=objc) |
| HideTitle                  | Hides the title of the window. [Apple Docs](https://developer.apple.com/documentation/appkit/nswindowtitlevisibility?language=objc)                                                                                                  |
| HideTitleBar               | Removes [NSWindowStyleMaskTitled](https://developer.apple.com/documentation/appkit/nswindowstylemask/nswindowstylemasktitled/) from the style mask                                                                                   |
| FullSizeContent            | Makes the webview fill the entire window. [Apple Docs](https://developer.apple.com/documentation/appkit/nswindowstylemask/nswindowstylemaskfullsizecontentview)                                                                      |
| UseToolbar                 | Adds a default toolbar to the window. [Apple Docs](https://developer.apple.com/documentation/appkit/nstoolbar?language=objc)                                                                                                         |
| HideToolbarSeparator       | Removes the line beneath the toolbar. [Apple Docs](https://developer.apple.com/documentation/appkit/nstoolbar/1516954-showsbaselineseparator?language=objc)                                                                          |

Preconfigured titlebar settings are available:

| Setting                     | Example                                        |
| --------------------------- | ---------------------------------------------- |
| `mac.TitleBarDefault()`     | ![](/img/reference/titlebar-default.webp)      |
| `mac.TitleBarHidden()`      | ![](/img/reference/titlebar-hidden.webp)       |
| `mac.TitleBarHiddenInset()` | ![](/img/reference/titlebar-hidden-inset.webp) |

Example:

```go
Mac: &mac.Options{
    TitleBar:     mac.TitleBarHiddenInset(),
}
```

Click [here](https://github.com/lukakerr/NSWindowStyles) for some inspiration on customising the titlebar.

#### Appearance

Appearance is used to set the style of your app in accordance with Apple's [NSAppearance](https://developer.apple.com/documentation/appkit/nsappearancename?language=objc) names.

名前: Appearance<br/> データ型: [`mac.AppearanceType`](#appearance-type)

##### Appearance 型

You can specify the application's [appearance](https://developer.apple.com/documentation/appkit/nsappearance?language=objc).

| 値                                                     | Description                                                     |
| ----------------------------------------------------- | --------------------------------------------------------------- |
| DefaultAppearance                                     | DefaultAppearance uses the default system value                 |
| NSAppearanceNameAqua                                  | The standard light system appearance                            |
| NSAppearanceNameDarkAqua                              | The standard dark system appearance                             |
| NSAppearanceNameVibrantLight                          | The light vibrant appearance                                    |
| NSAppearanceNameAccessibilityHighContrastAqua         | A high-contrast version of the standard light system appearance |
| NSAppearanceNameAccessibilityHighContrastDarkAqua     | A high-contrast version of the standard dark system appearance  |
| NSAppearanceNameAccessibilityHighContrastVibrantLight | A high-contrast version of the light vibrant appearance         |
| NSAppearanceNameAccessibilityHighContrastVibrantDark  | A high-contrast version of the dark vibrant appearance          |

Example:

```go
Mac: &mac.Options{
    Appearance: mac.NSAppearanceNameDarkAqua,
}
```

#### WebviewIsTransparent

Setting this to `true` will make the webview background transparent when an alpha value of `0` is used. This means that if you use `rgba(0,0,0,0)` for `background-color` in your CSS, the host window will show through. Often combined with [WindowIsTranslucent](#WindowIsTranslucent) to make frosty-looking applications.

名前: WebviewIsTransparent<br/> データ型: `bool`

#### WindowIsTranslucent

Setting this to `true` will make the window background translucent. Often combined with [WebviewIsTransparent](#WebviewIsTransparent) to make frosty-looking applications.

名前: WindowIsTranslucent<br/> データ型: `bool`

#### About

This configuration lets you set the title, message and icon for the "About" menu item in the app menu created by the "AppMenu" role.

名前: About<br/> データ型: [`*mac.AboutInfo`](#about-struct)

##### About struct

```go

type AboutInfo struct {
    Title   string
    Message string
    Icon    []byte
}
```

If these settings are provided, an "About" menu item will appear in the app menu (when using the `AppMenu` role). Given this configuration:

```go
//go:embed build/appicon.png
var icon []byte

func main() {
    err := wails.Run(&options.App{
        ...
        Mac: &mac.Options{
            About: &mac.AboutInfo{
                Title:   "My Application",
                Message: "© 2021 Me",
                Icon:    icon,
            },
        },
    })
```

The "About" menu item will appear in the app menu:

```mdx-code-block
<div class="text--center">
  <img
    src={require("@site/static/img/reference/about-menu.webp").default}
    class="screenshot"
  />
</div>
<br />
```

When clicked, that will open an about message box:

```mdx-code-block
<div class="text--center">
  <img
    src={require("@site/static/img/reference/about-dialog.webp").default}
    width="40%"
    class="screenshot"
  />
</div>
<br />
```

### Linux

[Linux固有のオプション](#linux)を定義します。

名前: Linux<br/> データ型: `*linux.Options`

#### Icon

Sets up the icon representing the window. This icon is used when the window is minimized (also known as iconified).

名前: Icon<br/> データ型: `[]byte`

Some window managers or desktop environments may also place it in the window frame, or display it in other contexts. On others, the icon is not used at all, so your mileage may vary.

NOTE: Gnome on Wayland at least does not display this icon. To have a application icon there, a `.desktop` file has to be used. On KDE it should work.

The icon should be provided in whatever size it was naturally drawn; that is, don’t scale the image before passing it. Scaling is postponed until the last minute, when the desired final size is known, to allow best quality.

#### WindowIsTranslucent

Setting this to `true` will make the window background translucent. Some window managers may ignore it, or result in a black window.

名前: WindowIsTranslucent<br/> データ型: `bool`