Usage with Player
Here you can find the instructions to add playback support to your rendered fretboard diagrams.
Installation
pnpm add @music-ui/core @music-ui/fretboardSee the Player page to know about the setup.
Chords playback
The @music-ui/fretboard package exports an initChordsWithPlayer function.
By default it selects all the [data-chord] elements, and expects them to have the following children:
- an element where the fretboard will be rendered, with the
.fretboardclass; - an element where the playback controls will be rendered, with the
.controlsclass.
<div data-chord>
<div
class="fretboard"
data-input="x32010"
data-chord-name="C major"
data-include-open-strings
data-text-property="note"
></div>
<div class="controls"></div>
</div>
<div data-chord>
<div
class="fretboard"
data-input="x5454x"
data-chord-name="D7b9"
data-crop
data-show-fret-numbers
data-text-property="note"
></div>
<div class="controls"></div>
</div>
<div data-chord>
<div
class="fretboard"
data-input="131244"
data-chord-name="F7#9"
data-barres="1:6:4,4:2"
data-show-fret-numbers
data-text-property="note"
></div>
<div class="controls"></div>
</div>As opposed to the initChords
function,
the data attributes are read from the .fretboard inner element and not
from the parent ([data-chord] in this case).
Setup code:
import { playerFactory } from "@music-ui/core";
import { initChordsWithPlayer } from "@music-ui/fretboard";
const player = playerFactory();
initChordsWithPlayer({ player });Output:
Render options
For a list of supported data attributes, see the initWithChord docs.
Last updated on