Skip to Content
ReactMusic NotationABCScoreWithPlayer

ABCScoreWithPlayer

The <ABCScoreWithPlayer> React component renders ABC notation on screen with playback support.

Installation

pnpm add @music-ui/core @music-ui/react

Usage

The following code renders a score with the passed notes and the playback buttons:

Wrap your app in a <PlayerProvider> if you want to use playback features.

import { playerFactory } from "@music-ui/core"; import { ABCScoreWithPlayer, PlayerProvider } from "@music-ui/react"; import "@music-ui/abc/styles.css"; const player = playerFactory(); function App() { return ( <PlayerProvider player={player}> <main> <h1>My App</h1> {/* rest of your app */} <ABCScoreWithPlayer> CDEF GABc| </ABCScoreWithPlayer> </main> </PlayerProvider> ); }

Output:

120

With free tempo:

import { playerFactory } from "@music-ui/core"; import { ABCScoreWithPlayer, PlayerProvider } from "@music-ui/react"; import "@music-ui/abc/styles.css"; const player = playerFactory(); function App() { return ( <PlayerProvider player={player}> <main> <h1>My App</h1> {/* rest of your app */} <ABCScoreWithPlayer> M: 1/1 L: 1/1 Q: 200 C D E F G A B c || c d e f g a b c' | </ABCScoreWithPlayer> </main> </PlayerProvider> ); }
200

Component props

In addition to the ABCScore component props, the component accepts the following props:

NameTypeDefault ValueDescription
showPianobooleanfalseDisplays or hides the piano view
pianoOptionsobjectDEFAULT_PIANO_OPTIONSProps expected by the Piano renderer
showTempoControlsbooleantrueDisplays or hides the tempo controls
highlightBarsbooleanfalseHighlights the current played bar

Props showcase

A showcase of the component props:

import { playerFactory } from "@music-ui/core"; import { ABCScoreWithPlayer, PlayerProvider } from "@music-ui/react"; import "@music-ui/abc/styles.css"; import "@music-ui/piano/styles.css"; const player = playerFactory(); function App() { return ( <PlayerProvider player={player}> <ABCScoreWithPlayer highlightBars> CDEF GABc|cBAGFEDC| </ABCScoreWithPlayer> <ABCScoreWithPlayer showTempoControls={false}> CDEF GABc| </ABCScoreWithPlayer> <ABCScoreWithPlayer showPiano pianoOptions={{ showOctaves: true, octaves: 3 }}> CDEF GABc| </ABCScoreWithPlayer> </PlayerProvider> ); }

highlightBars

120

showTempoControls

showPiano

180
Last updated on