Lyrics
Lyrics render with each syllable positioned under the beat it belongs to. alphaTab reads lyric lines from the source file or accepts them programmatically through the API.
Aligning to beatsโ
Each lyric syllable sits under its target beat โ the way songbook vocal lines are typeset so a singer reads word and melody at the same glance. Hyphens between syllables indicate a continuation across beats, and underscores extend a syllable across held notes.
Multi-verse handlingโ
Multiple verses stack below the staff, one line per verse โ the way hymnals and folk songbooks fit two, three, or four sets of words under a single melodic line. alphaTab preserves the order the source file provides. Pass extra strings to alphaTex's \lyrics directive to add verses.
Placementโ
score.stylesheet.lyricsPlacement decides where the lyrics go, like the lyrics setting of the Guitar Pro stylesheet. The placement is relative to the standard notation staff: LyricsPlacement.Below (the default) shows them below it, LyricsPlacement.Above above it. When standard notation is not shown, the lyrics move to the next shown staff, in the order tablature, slash, numbered: a tab-only guitar part shows them below the tabs, which keeps the space above the tabs free for bends, whammy bar and vibrato. LyricsPlacement.Hidden hides the lyrics of the score. In alphaTex, use \lyricsPlacement below|above|hidden. The Guitar Pro importer and exporter read and write the setting; the MusicXML importer sets Above when all lyrics of the file are placed above the staff.
Rendering fontsโ
Lyrics use a dedicated font entry so a chart can restyle them without touching the rest of the score โ the typical case for a hymnal that pairs a serif melody with a large sans-serif lyric line. Point display.resources.wordsFont at any registered family to change size, weight, or face.
See Custom text fonts for the full list of font slots and Font family fallbacks for handling missing families.
Show it in codeโ
Lyrics render on by default. To hide them from a printout โ for instance, an instrumental lead sheet โ flip the EffectLyrics element off:
import * as alphaTab from '@coderline/alphatab';
const container = getAlphaTabContainer();
const api = new alphaTab.AlphaTabApi(container, {
core: { file: '/scores/song.gp' },
notation: {
elements: new Map([
[alphaTab.NotationElement.EffectLyrics, false],
]),
},
});
getAlphaTabContainer() is a placeholder for the platform-specific render target. Lyrics can also be attached at runtime through the Lyrics model on the model reference.
Where to look nextโ
- Toggling notation elements off โ hide any category globally.
RenderStylesheet.lyricsPlacementโ the stylesheet entry for the lyrics placement.- Custom text fonts โ configure the lyric font family and size.
- Font family fallbacks โ handle missing font families gracefully.
notation.elementsโ the settings entry point for the element map.Lyricsโ the model type for attaching lyrics programmatically.