SonicFrame v1.3.2

Captions

A line of text under the wave: a transcript's first words, a title, a note. It fades out on the right, can carry badges, and its full text reaches screen readers.

Adding one

import { caption } from 'sonicframe';

frame.use(
    caption({
        text: 'I met a little elf-man, once, down where the lilies blow.',
        badges: ['auto', 'en'],
    }),
);

Hover it, focus the wave or tap the caption to see the tooltip with the fuller text.

For screen readers

The full text goes in the wave's aria-describedby, next to any ids your page put there (it never removes yours), so a screen reader reads it when the person reaches the wave. Text goes in as text, never as HTML.

Options

Option What it does
text The caption.
badges Up to three short marks before the text (['auto', 'pt']).
tooltip What the tooltip shows; left out, the caption again, longer.
tooltipMax The most characters the tooltip shows, cut at a word: 280, up to 2000 (a section's own max too). Anything that is not a number is the default.
height The line's height: 20, at least 1. A number counts in CSS pixels; a length is written with its unit ('1.25rem', '20px').
a11y.tooltip.readable Writes the tooltip's text in black or white, whichever reads on its color (4.5:1). On by default; off, the page's color for text on the played color.

set(text) replaces the text (null removes the line and gives its room back to the wave), and setTooltip(content) the tooltip.

The tooltip can also be a list of sections, one line each, every one cut at its own max: