TouchBar

    Process: Main

    Creates a new touch bar with the specified items. Use BrowserWindow.setTouchBar to add the TouchBar to a window.

    Note: The TouchBar API is currently experimental and may change or be removed in future Electron releases.

    Tip: If you don’t have a MacBook with Touch Bar, you can use to test Touch Bar usage in your app.

    A reference to the TouchBarButton class.

    TouchBarColorPicker

    TouchBarGroup

    A typeof TouchBarGroup reference to the TouchBarGroup class.

    TouchBarLabel

    A typeof TouchBarLabel reference to the TouchBarLabel class.

    TouchBarPopover

    A typeof TouchBarPopover reference to the TouchBarPopover class.

    TouchBarScrubber

    A typeof TouchBarScrubber reference to the TouchBarScrubber class.

    A typeof TouchBarSegmentedControl reference to the TouchBarSegmentedControl class.

    TouchBarSlider

    TouchBarSpacer

    A reference to the TouchBarSpacer class.

    TouchBarOtherItemsProxy

    A reference to the TouchBarOtherItemsProxy class.

    The following properties are available on instances of TouchBar:

    touchBar.escapeItem

    A TouchBarItem that will replace the “esc” button on the touch bar when set. Setting to null restores the default “esc” button. Changing this value immediately updates the escape item in the touch bar.

    Examples

    Below is an example of a simple slot machine touch bar game with a button and some labels.

    1. Save the above file to your computer as touchbar.js
    2. Install Electron via npm install electron
    3. Run the example inside Electron:

    You should then see a new Electron window and the app running in your touch bar (or touch bar emulator).