Skip to content

Commit bedd478

Browse files
committed
chore: fixup documentation
1 parent dd931e1 commit bedd478

File tree

3 files changed

+54
-10
lines changed

3 files changed

+54
-10
lines changed

docs/api/base-window.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,13 +1262,37 @@ Sets the properties for the window's taskbar button.
12621262
12631263
#### `win.setAccentColor(accentColor)` _Windows_
12641264

1265-
* `accentColor` boolean | string - The accent color for the window. By default, follows user preference in System Settings. Set to `false` to explicitly disable, or set the color in Hex, RGB, RGBA, HSL, HSLA or named CSS color format. Alpha values will be ignored.
1265+
* `accentColor` boolean | string - The accent color for the window. By default, follows user preference in System Settings.
12661266

12671267
Sets the system accent color and highlighting of active window border.
12681268

1269+
The `accentColor` parameter accepts the following values:
1270+
1271+
* **Color string** - Sets a custom accent color using standard CSS color formats (Hex, RGB, RGBA, HSL, HSLA, or named colors). Alpha values in RGBA/HSLA formats are ignored and the color is treated as fully opaque.
1272+
* **`true`** - Uses the system's default accent color from user preferences in System Settings.
1273+
* **`false`** - Explicitly disables accent color highlighting for the window.
1274+
1275+
Examples:
1276+
1277+
```js
1278+
const win = new BrowserWindow({ frame: false })
1279+
1280+
// Set red accent color.
1281+
win.setAccentColor('#ff0000')
1282+
1283+
// RGB format (alpha ignored if present).
1284+
win.setAccentColor('rgba(255,0,0,0.5)')
1285+
1286+
// Use system accent color.
1287+
win.setAccentColor(true)
1288+
1289+
// Disable accent color.
1290+
win.setAccentColor(false)
1291+
```
1292+
12691293
#### `win.getAccentColor()` _Windows_
12701294

1271-
Returns `string | null` - the system accent color and highlighting of active window border in RGB format.
1295+
Returns `string | boolean` - the system accent color and highlighting of active window border in Hex RGB format.
12721296

12731297
If a color has been set for the window that differs from the system accent color, the window accent color will
12741298
be returned. Otherwise, the system accent color will be returned, if one is enabled.

docs/api/browser-window.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,13 +1442,37 @@ Sets the properties for the window's taskbar button.
14421442
14431443
#### `win.setAccentColor(accentColor)` _Windows_
14441444

1445-
* `accentColor` boolean | string - The accent color for the window. By default, follows user preference in System Settings. Set to `false` to explicitly disable, or set the color in Hex, RGB, RGBA, HSL, HSLA or named CSS color format. Alpha values will be ignored.
1445+
* `accentColor` boolean | string - The accent color for the window. By default, follows user preference in System Settings.
14461446

14471447
Sets the system accent color and highlighting of active window border.
14481448

1449+
The `accentColor` parameter accepts the following values:
1450+
1451+
* **Color string** - Sets a custom accent color using standard CSS color formats (Hex, RGB, RGBA, HSL, HSLA, or named colors). Alpha values in RGBA/HSLA formats are ignored and the color is treated as fully opaque.
1452+
* **`true`** - Uses the system's default accent color from user preferences in System Settings.
1453+
* **`false`** - Explicitly disables accent color highlighting for the window.
1454+
1455+
Examples:
1456+
1457+
```js
1458+
const win = new BrowserWindow({ frame: false })
1459+
1460+
// Set red accent color.
1461+
win.setAccentColor('#ff0000')
1462+
1463+
// RGB format (alpha ignored if present).
1464+
win.setAccentColor('rgba(255,0,0,0.5)')
1465+
1466+
// Use system accent color.
1467+
win.setAccentColor(true)
1468+
1469+
// Disable accent color.
1470+
win.setAccentColor(false)
1471+
```
1472+
14491473
#### `win.getAccentColor()` _Windows_
14501474

1451-
Returns `string | null` - the system accent color and highlighting of active window border in RGB format.
1475+
Returns `string | boolean` - the system accent color and highlighting of active window border in Hex RGB format.
14521476

14531477
If a color has been set for the window that differs from the system accent color, the window accent color will
14541478
be returned. Otherwise, the system accent color will be returned, if one is enabled.

shell/browser/api/electron_api_base_window.cc

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,13 +1112,9 @@ v8::Local<v8::Value> BaseWindow::GetAccentColor() const {
11121112
v8::Isolate* isolate = v8::Isolate::GetCurrent();
11131113
auto accent_color = window_->GetAccentColor();
11141114

1115-
if (std::holds_alternative<bool>(accent_color)) {
1115+
if (std::holds_alternative<bool>(accent_color))
11161116
return v8::Boolean::New(isolate, std::get<bool>(accent_color));
1117-
} else if (std::holds_alternative<std::string>(accent_color)) {
1118-
return gin::StringToV8(isolate, std::get<std::string>(accent_color));
1119-
}
1120-
1121-
return v8::Null(isolate);
1117+
return gin::StringToV8(isolate, std::get<std::string>(accent_color));
11221118
}
11231119
#endif
11241120

0 commit comments

Comments
 (0)