Skip to Content

ChordWithPlayer

The <ChordWithPlayer> React component adds playback functionality to the <Chord> component.

Installation

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

Usage

The following code renders a chord with the passed input and the playback buttons:

Wrap your app in a <PlayerProvider> if you want to use playback features.
See the Player page to know about the setup.

import { playerFactory } from "@music-ui/core"; import { ChordWithPlayer, PlayerProvider } from "@music-ui/react"; const player = playerFactory(); function App() { return ( <PlayerProvider player={player}> <main> <h1>My App</h1> {/* rest of your app */} <ChordWithPlayer input="x32010" includeOpenStrings /> </main> </PlayerProvider> ); }

You can read more about the input shorthand format here.

Output:

You can render multiple chords, each with independent playback feature:

import { playerFactory } from "@music-ui/core"; import { ChordWithPlayer, PlayerProvider } from "@music-ui/react"; const player = playerFactory(); function App() { return ( <PlayerProvider player={player}> <ChordWithPlayer input="x32010" textProperty="note" includeOpenStrings /> <ChordWithPlayer input="133111" chordName="F minor" textProperty="note" barres="1" /> </PlayerProvider> ); }

Component props

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

NameTypeDefault ValueDescription
playedNoteColorstring#ff636cThe played note color
instrumentstringacoustic_guitar_nylonThe playback instrument
playLabelstringPlayThe playback button label
arpeggioLabelstringArpeggioThe arpeggio playback button label
arpeggioSpeednumber120The arpeggio playback tempo
Last updated on