Skip to main content

ChordDiagram

Renders an SVG fretboard fingering diagram for guitar, ukulele, and other fretted instruments.

Usage

import { ChordDiagram, createChord } from 'react-notation'

const cMajor = createChord({
beat: 1,
duration: 'whole',
symbol: 'C',
root: 'C',
// index 0 = lowest string (low E on guitar)
// -1 = muted, 0 = open, N = fret number
voicing: [-1, 3, 2, 0, 1, 0],
})

<ChordDiagram chord={cMajor} />

Props

PropTypeDefaultDescription
chordChordRequired. Must have a voicing array.
stringsnumber6Number of strings (4 for ukulele, 6 for guitar, etc.).
fretsnumber4Number of frets to display.
showLabelbooleantrueShow the chord symbol below the diagram.
widthnumber80SVG width in pixels. Height is derived automatically.
classNamestringAdditional CSS class on the SVG element.
...restSVGAttributes<SVGSVGElement>All standard SVG props forwarded.

ChordDiagram is a forwardRef component.

Voicing format

voicing is an array of fret numbers, one per string:

ValueMeaning
-1Muted string (rendered as ×)
0Open string (rendered as ○)
1–NFret number (rendered as filled dot)

Index 0 is the lowest-pitched string (thickest, displayed on the left).

// Guitar C major: x32010
voicing: [-1, 3, 2, 0, 1, 0]

// Guitar Am: 002210
voicing: [0, 0, 2, 2, 1, 0]

// Ukulele C: 0003
voicing: [0, 0, 0, 3]

High-neck chords

When the minimum pressed fret is above the default window (frets), the diagram omits the nut and shows a fret position number instead:

// Barre at 5th position — shows "5" indicator
<ChordDiagram chord={aAt5th} />

Theming

ChordDiagram responds to these CSS custom properties:

TokenDefaultControls
--notation-diagram-dot-colorcurrentColorFinger dot fill
--notation-diagram-marker-colorcurrentColorOpen/muted marker stroke
--notation-diagram-grid-colorcurrentColorFret and string lines
--notation-diagram-nut-colorcurrentColorNut bar fill
--notation-diagram-text-colorcurrentColorFret position number
--notation-color-chordinheritChord label below diagram
--notation-font-familyGeorgia, serifChord label font
--notation-font-weight-chord600Chord label weight

Known limitations

  • Barre chords are not rendered with a curved barre indicator — dots are shown individually.
  • Finger numbers inside dots are not yet supported.