Chord
The <Chord> React component renders guitar chords diagrams.
Installation
pnpm add @music-ui/reactUsage
The following code renders an open C chord:
import { Chord } from "@music-ui/react";
function App() {
return (
<main>
<h1>My App</h1>
{/* rest of your app */}
<Chord input="x32010" chordName="C major" />
</main>
);
}You can read more about the input shorthand format
here.
Output:
Component props
In addition to the Fretboard component props, the component accepts the following props:
| Name | Type | Default Value | Description |
|---|---|---|---|
input | string | The chord input (e.g. x32010) | |
chordName | string | The chord name (e.g. “C major”) | |
barres | Barre | Barres[] | One or more chord barres | |
includeOpenStrings | boolean | false | Shows the open string positions |
showName | boolean | false | Shows the chord name |
Props showcase
A showcase of the component props:
import { Chord } from "@music-ui/react";
function App() {
return (
<>
<Chord input="x32010" chordName="C major" showName />
<Chord
input="x32010"
chordName="C minor"
textProperty="note"
includeOpenStrings
/>
<Chord
input="x355421"
barres={{ fret: 3, stringFrom: 5 }}
chordName="C minor"
crop
showName={false}
/>
</>
);
}showName
textProperty and includeOpenStrings
In order to display the right note name (e.g. Eb vs D#), the chordName
property must include the chord quality (e.g. major or minor), see:
import { Chord } from "@music-ui/react";
function App() {
return (
<>
<Chord input="133111" textProperty="note" includeOpenStrings />
<Chord
input="133111"
chordName="F minor"
textProperty="note"
includeOpenStrings
/>
</>
);
}No chordName: displays G# on the third string, first fret:
Right chordName: displays Ab on the third string, first fret:
barres and crop
Last updated on