<mq-fretboard>

Guitar/bass fretboard with slot-based content placement. The component positions, you style. Horizontal or vertical orientation, configurable string count and fret range, inlays, full-neck, left-handed, and multi-string span slots for barres via extra-slots.

← Back to index

Install

npm install @hsablonniere/musiq
import '@hsablonniere/musiq/mq-fretboard';

API

Attributes / Properties

Attribute Property Type Default Description
strings strings number 6 Number of strings (4 = ukulele, 5 = bass, 6 = guitar, etc.)
start-fret startFret number 1 First fret displayed. When > 1, the nut is replaced by a fret line
end-fret endFret number 12 Last fret displayed
orientation orientation "horizontal" | "vertical" "horizontal" Layout direction of the fretboard
fret-numbers fretNumbers string "" Frets to label: "all" or comma-separated list (e.g. "3,5,7,9,12"). Empty string (default) hides all fret numbers
inlays inlays boolean false Show position dots at standard frets (3, 5, 7, 9, 12…). Double dot at 12 and 24
full-neck fullNeck boolean false Extend frets and nut edge to edge (instead of string to string)
left-handed leftHanded boolean false Mirror the fretboard for left-handed players
extra-slots extraSlots string "" Comma-separated multi-string span slots (e.g. "s1-s6-f5") for barres or capos

Slots

Slot Description
s{N}-marker Before the nut (open strings, muted markers)
s{N}-f{F} Fret F on string N
s{A}-s{B}-f{F} Fret F spanning strings A to B (requires extra-slots)

CSS Custom Properties

Property Default Description
--mq-fretboard-fret-color #000 Fret wire color
--mq-fretboard-fret-width 1px Fret wire thickness
--mq-fretboard-string-color #000 String color
--mq-fretboard-string-width 1px String thickness
--mq-fretboard-nut-color #000 Nut color (thick bar at fret 0)
--mq-fretboard-nut-width 3px Nut thickness
--mq-fretboard-nut-radius 0 Nut border radius
--mq-fretboard-neck-color none Neck background color
--mq-fretboard-inlay-color #000 Inlay position dot color
--mq-fretboard-inlay-size 6px Inlay position dot diameter

CSS Parts

Part Description
fret-number Fret number labels below (horizontal) or beside (vertical) each fret

Default

Default configuration: 6-string guitar, frets 1–12, horizontal orientation.

Fret numbers

Set to "all" to label every fret, or a comma-separated list for specific frets.

fret-numbers="all"

fret-numbers="3,5,7,9,12"

Vertical

With orientation="vertical", the neck goes top to bottom. Fret numbers on the left.

Scale pattern — slotted content

A minor pentatonic — position 1. Place content via named slots: s{string}-f{fret} for fretted notes. The component positions, you style. = root, = scale tone.

A C D E G A C D E G A C

Full neck scale

Full 12-fret display with the complete A minor pentatonic scale.

E G A C D E A C D E G A E G A C D G A C D E G C D E G A E G A C D E

Custom range

Display any fret range. When start-fret > 1, a fret line replaces the nut.

start-fret="5" end-fret="9"

start-fret="1" end-fret="24"

Other instruments

Set the number of strings. Works for ukulele (4), bass (5), guitar (6), 7-string, etc.

strings="4" (ukulele) — frets 1–7

strings="5" (bass) — frets 1–12

Fret drawing mode

By default, frets and nut span from the first to the last string. Add full-neck to extend them edge to edge.

String to string (default)

full-neck

Inlays

Position dots at standard frets (3, 5, 7, 9, 12, 15…). Double dot at 12 and 24. Disabled by default. Add inlays attribute to enable.

Without inlays (default)

With inlays

Style — CSS parts & custom properties

Style structural elements via CSS parts and custom properties.

Vertical scale

Same scale pattern as above, but in vertical orientation.

E G A C D E A C D E G A E G A C D G A C D E G C D E G A E G A C D E

Left-handed

Mirror the fretboard for left-handed players. Works with both orientations.

E G A C D E A C D E G A E G A C D G A C D E G C D E G A E G A C D E

Horizontal — left-handed

E G A C A C D E E G A G A C D C D E G E G A C

Vertical — left-handed

Extra slots — multi-string spans

Declare span slots via extra-slots="s1-s6-f5" (comma-separated). Each entry creates a s{A}-s{B}-f{F} slot that stretches across strings A to B at fret F. Useful for barres, capos, or any element spanning multiple strings.

A E A D G C

Horizontal — barre at fret 5 (strings 1–6) + individual notes

A E A D G C

Vertical — same barre pattern