sumi

Beyond · The terminal

Light and dark

A terminal has its own colour scheme, and sumi follows it. On a real terminal sumi probes the background with an OSC 11 query and resolves to light or dark (dark if the terminal does not answer); you can also force it through RunOptions.ColorScheme. That resolved scheme drives both the prefers-color-scheme media query and the light-dark() colour function.

light-dark(<light>, <dark>) keeps both colours and picks one at the moment a cell is drawn, according to the active scheme. It is the compact way to give a value two forms without writing a media query.

This runner resolves to the dark scheme. The note below is hardcoded to near-black #1a1a1a, which all but disappears against the dark background.

Your turn

Give the note a colour for each scheme so it stays readable:

.note {
    color: light-dark(#1a1a1a, #e6e6e6);
}

Press Run: because the scheme here is dark, light-dark() picks the light #e6e6e6 arm and the note becomes legible. Solve shows the finished version; Reset restores the start.

⌘↵ to run