f ((Date.now() - startTime) >= spinLength) {  
            finishSpin()  
          } else {  
            // Slow down a bit on each spin  
            timeout *= 1.1  
            setTimeout(spinReels, timeout)  
          }  
        }  
      
        spinReels()  
      }  
    })  
      
    const getRandomValue = () => {  
      const values = ['ð', 'ð', '7ï¸â£', 'ð', 'ð', 'â­', 'ð', 'ð']  
      return values[Math.floor(Math.random() * values.length)]  
    }  
      
    const updateReels = () => {  
      reel1.label = getRandomValue()  
      reel2.label = getRandomValue()  
      reel3.label = getRandomValue()  
    }  
      
    const finishSpin = () => {  
      const uniqueValues = new Set([reel1.label, reel2.label, reel3.label]).size  
      if (uniqueValues === 1) {  
        // All 3 values are the same  
        result.label = 'ð° Jackpot!'  
        result.textColor = '#FDFF00'  
      } else if (uniqueValues === 2) {  
        // 2 values are the same  
        result.label = 'ð Winner!'  
        result.textColor = '#FDFF00'  
      } else {  
        // No values are the same  
        result.label = 'ð Spin Again'  
        result.textColor = null  
      }  
      spinning = false  
    }  
      
    const touchBar = new TouchBar({  
      items: [  
        spin,  
        new TouchBarSpacer({ size: 'large' }),  
        reel1,  
        new TouchBarSpacer({ size: 'small' }),  
        reel2,  
        new TouchBarSpacer({ size: 'small' }),  
        reel3,  
        new TouchBarSpacer({ size: 'large' }),  
        result  
      ]  
    })  
      
    let window  
      
    app.whenReady().then(() => {  
      window = new BrowserWindow({  
        frame: false,  
        titleBarStyle: 'hiddenInset',  
        width: 200,  
        height: 200,  
        backgroundColor: '#000'  
      })  
      window.loadURL('about:blank')  
      window.setTouchBar(touchBar)  
    })  
    

###  Running the above example  â

To run the example above, you'll need to (assuming you've got a terminal open
in the directory you want to run the example):

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

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

[ Edit this page
](https://github.com/electron/electron/edit/main/docs/api/touch-bar.md)

[ Previous  systemPreferences  ](/docs/latest/api/system-preferences) [ Next
Tray  ](/docs/latest/api/tray)

  * Class: TouchBar 
    * ` new TouchBar(options) `
    * Static Properties 
      * ` TouchBarButton `
      * ` TouchBarColorPicker `
      * ` TouchBarGroup `
      * ` TouchBarLabel `
      * ` TouchBarPopover `
      * ` TouchBarScrubber `
      * ` TouchBarSegmentedControl `
      * ` TouchBarSlider `
      * ` TouchBarSpacer `
      * ` TouchBarOtherItemsProxy `
    * Instance Properties 
      * ` escapeItem `
  * Examples 
    * Running the above example 

Docs

  * [ Getting Started ](/docs/latest/)
  * [ API Reference ](/docs/latest/api/app)

Checklists

  * [ Performance ](/docs/latest/tutorial/performance)
  * [ Security ](/docs/latest/tutorial/security)

Tools

  * [ Electron Forge ](https://electronforge.io)
  * [ Electron Fiddle ](/fiddle)

Community

  * [ Governance ](/governance)
  * [ Resources ](/community)
  * [ Discord  ](https://discordapp.com/invite/APGC3k5yaH)
  * [ Twitter  ](https://twitter.com/electronjs)
  * [ Mastodon  ](https://social.lfx.dev/@electronjs)
  * [ Stack Overflow  ](https://stackoverflow.com/questions/tagged/electron)

More

  * [ GitHub  ](https://github.com/electron/electron)
  * [ Open Collective  ](https://opencollective.com/electron)
  * [ Infrastructure Dashboard  ](https://p.datadoghq.com/sb/c44e1df0-85d7-11ee-94c9-da7ad0900002-c245f7ef47d0d0c32abecdc0938c2a85)

[ ![OpenJS Foundation Logo