JSFiddle - React, Tailwind, and code Playground

by Daniel Kuschny

HTML

<div id="app">
  <div id="header">
    alphaTab
  </div>

  <div id="scroll">
    <div id="score"></div>

    <!-- Just to emulate the dynamic island -->
    <div id="dynamicIsland"></div>
  </div>

  <div id="toolbar">
    <button id="play">Play</button>
  </div>
</div>

CSS

html,
body {
  padding: 0;
  margin: 0;
  height: 100%;
  font-family:
    'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande',
    'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

button {
  background-color: #2f80ed;
  color: #fff;
  border-radius: 8px;
  border-style: none;
  box-sizing: border-box;
  font-size: 16px;
  font-weight: 500;
  padding: 1rem 1.6rem;
  text-align: center;
  cursor: pointer;
}

button:hover {
  background-color: #1366d6;
  box-shadow:
    rgba(0, 0, 0, 0.05) 0 5px 30px,
    rgba(0, 0, 0, 0.05) 0 1px 4px;
  opacity: 1;
  transform: translateY(0);
  transition-duration: 0.35s;
}
button:active {
  box-shadow:
    rgba(0, 0, 0, 0.1) 0 3px 6px 0,
    rgba(0, 0, 0, 0.1) 0 0 10px 0,
    rgba(0, 0, 0, 0.1) 0 1px 4px -1px;
  transform: translateY(2px);
  transition-duration: 0.35s;
}

#app > div {
  display: flex;
}

#header,
#toolbar {
  background: #426d9d;
  color: #fff;
  background: linear-gradient(
    149deg,
    rgba(66, 109, 157, 1) 0%,
    rgba(76, 155, 252, 1) 49%,
    rgba(116, 161, 212, 1) 100%
  );
  display: flex;
  align-items: center;
  padding: 1rem;
}

#scroll {
  flex-grow: 1;
  align-items: center;
  /* Handle dynamic island */
  overflow: auto;
}

#score {
  min-width: 100%;
}

#dynamicIsland {
  position: absolute;
  top: 50%;
  left: 50px;
  background:#000;
  width: 30px;
  height: 200px;
  border-radius: 30px;
  z-index: 10000;
  transform: translateY(-50%)
}

/* Styles for player */
.at-cursor-bar {
  /* Defines the color of the bar background when a bar is played */
  background: rgba(255, 242, 0, 0.25);
}

.at-selection div {
  /* Defines the color of the selection background */
  background: rgba(64, 64, 255, 0.1);
}

.at-cursor-beat {
  /* Defines the beat cursor */
  background: rgba(64, 64, 255, 0.75);
  width:...

JavaScript

import * as alphaTab from 'https://cdn.jsdelivr.net/npm/@coderline/alphatab@latest/dist/alphaTab.mjs';

window.onload = () => {
  const el = document.getElementById('score');
  let at = new alphaTab.AlphaTabApi(el, {
    player: {
      enablePlayer: true,
      soundFont:
        'https://cdn.jsdelivr.net/npm/@coderline/alphatab@alpha/dist/soundfont/sonivox.sf2',
      scrollElement: '#scroll',
      scrollMode: 'offscreen',
      scrollOffsetX: -100,
    },
    display: {
      layoutMode: 'horizontal',
      firstStaffPaddingLeft: 50
    },
  });

  at.tex(
    `\\tempo 100
  \\track  
  5.5.4*4 |  5.5.4*4 |  5.5.4*4 |  5.5.4*4 |  5.5.4*4 |  5.5.4*4 |
  5.5.4*4 |  5.5.4*4 |  5.5.4*4 |  5.5.4*4 |  5.5.4*4 |  5.5.4*4 |
  5.5.4*4 |  5.5.4*4 |  5.5.4*4 |  5.5.4*4 |  5.5.4*4 |  5.5.4*4 |
  5.5.4*4 |  5.5.4*4 |  5.5.4*4 |  5.5.4*4 |  5.5.4*4 |  5.5.4*4 |
  `,
    'all',
  );

  document.getElementById('play').onclick = function (e) {
    e.stopPropagation();
    at.playPause();
  };
};