Real songs often have two singers performing simultaneously, or a main melody with background harmonies weaving in and out. Accompanist Lyrics UI models this through a parent–child relationship betweenDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/6xingyv/accompanist-lyrics-ui/llms.txt
Use this file to discover all available pages before exploring further.
KaraokeLine.MainKaraokeLine and KaraokeLine.AccompanimentKaraokeLine. The main line anchors the position in the list; accompaniment lines orbit around it, appearing and disappearing with scale, fade, slide, and expand transitions.
The Data Model
The core of the duet data model isKaraokeLine.MainKaraokeLine, which carries an optional list of accompaniment lines:
AccompanimentKaraokeLine has its own independent:
- syllable list — with separate start/end timestamps per syllable
startandendtimestamps — the window during which the accompaniment line is activealignment— typicallyKaraokeAlignment.Endto visually separate it from the main voice
Layout
Accompaniment lines are rendered as siblings of their anchor main line within a singleColumn. KaraokeLineText splits the accompaniment lines into two groups relative to the main line’s start time:
- Lines where
accompanimentLine.start < mainLine.startare placed above the main line. - Lines where
accompanimentLine.start >= mainLine.startare placed below the main line.
Alignment
Duet partners typically useKaraokeAlignment.End to anchor them to the trailing edge of the layout — the visual right in LTR layouts and the visual left in RTL layouts. The library maps KaraokeAlignment to visual alignment by combining it with RTL text direction detection:
KaraokeAlignment.End on an LTR line produces right-alignment (isRightAligned = true), while the same alignment on an RTL line produces left-alignment — exactly what you want for a duet where both parties are singing in the same script.
Animated Visibility
Accompaniment lines animate in and out using a combination of four simultaneous transitions, all sharing a 600 ms duration:scaleIn/scaleOut— scales from/to the line’s anchor corner (the alignment edge)fadeIn/fadeOut— smooth opacity transitionslideInVertically/slideOutVertically— slides in from the direction the line will appearexpandVertically/shrinkVertically— avoids layout jump by smoothly reserving space
[start - 600ms, end + 600ms]:
Accompaniment Text Style
Main vocal lines and accompaniment lines use separate text styles, making it easy to distinguish the two voices at a glance:KaraokeLineText, the style selector checks line is KaraokeLine.AccompanimentKaraokeLine and applies accompanimentLineTextStyle for accompaniment lines and normalLineTextStyle for everything else:
0.6f) and inactive alpha (0.2f) compared to the main line, making the main voice the clear focal point even when both lines are visible simultaneously.
The accompaniment-to-main anchor mapping is computed automatically by
KaraokeLyricsView based on timestamp proximity. For each AccompanimentKaraokeLine in the flat lyrics.lines list, the library finds the nearest main line by locating the closest non-accompaniment line by index (the one immediately before and the one immediately after), then choosing whichever has the smaller absolute difference between its start time and the accompaniment line’s start time. You do not need to supply explicit anchor indices in your data model.