Customizing the browser window

The BrowserWindow class is used to create and manage the browser windows. We have used this class throughout this book. It provides a lot of features more than just creating a window. The window can be customized as per your requirement using this class. This class provides a rich set of methods and events; let's look at some of them here in this section.

We have just set the width and height inside the browser. However, it can accept a huge list of valid options as the constructor arguments. Some of the options are platform specific that will work only on that platform. Here are some of the important option that you can pass inside the constructor; visit the Electron documentation for a complete list of options-all the options listed here are optional:

  • width: Width of the window.
  • height: Height of the window.
  • x: Left offset.
  • y: Top offset.
  • maxWidth, minWidth: You can set these two options to set the minimum and maximum resizable width of the window.
  • maxHeight, maxHeight: Use these options to set the minimum and maximum resizable height of the window.
  • closable: Enable/disable the close button; not available in Linux.
  • focusable: Whether the window can be focused or not.
  • fullscreen: Show the window in full screen.
  • kiosk: Enables the kiosk mode; this option is good if you are developing the application to run inside the kiosk machine.
  • title: Title of the window.
  • icon 
  • backgroundColor
  • vibrancy: Add the vibrancy effect to the window on macOS. The values can be appearance-based, light, dark, titlebar, selection, menu, popover, sidebar, medium-light, or ultra-dark.
  • webPreference: Use this to provide the settings to the web page that is rendering on this window.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.10.201