audiocn-svelte
Esc

Start typing to search the docs

LCD Display

A dot-matrix screen for labelled readouts and settings, backlit in the light theme and glowing in the dark one, with dropdown values.

5 min read · 908 words

Model
Effort

Installation

$ pnpm dlx shadcn-svelte@latest add https://juddisjudd.github.io/audiocn-svelte/r/lcd-display.json

Usage

<script lang="ts">
	import {
		LcdDisplay,
		LcdDisplayLabel,
		LcdDisplayRow,
		LcdDisplayValue,
	} from "#lib/components/ui/lcd-display/index.js";
</script>

<LcdDisplay>
	<LcdDisplayRow>
		<LcdDisplayLabel>Tempo</LcdDisplayLabel>
		<LcdDisplayValue>128.0</LcdDisplayValue>
	</LcdDisplayRow>
</LcdDisplay>

The screen follows your theme. Its ink is the theme's --primary, so it takes the colour of any theme. In light mode it is a backlit LCD: pale glass tinted by the ink, with dark pixels, like a calculator. In dark mode it is dark glass where the ink itself glows. Labels are dim, values are bright, and a value dims for a moment when its text changes, like segments redrawing.

Set appearance="light" or appearance="dark" to keep one look in both modes, for example a dark screen on a light page.

Anatomy

<LcdDisplay>
	<LcdDisplayRow>
		<LcdDisplayLabel />
		<LcdDisplaySelect type="single">
			<LcdDisplaySelectTrigger />
			<LcdDisplaySelectContent>
				<LcdDisplaySelectItem />
			</LcdDisplaySelectContent>
		</LcdDisplaySelect>
	</LcdDisplayRow>
	<LcdDisplaySeparator />
	<LcdDisplayRow>
		<LcdDisplayLabel />
		<LcdDisplayValue />
	</LcdDisplayRow>
	<LcdDisplayStatus />
</LcdDisplay>

A row holds a label and either a read-only LcdDisplayValue or an LcdDisplaySelect. LcdDisplaySelect is bits-ui's Select, so it takes the same props: type, value (bindable), onValueChange and items. Pass items to show each value's label in the trigger.

<script lang="ts">
	const efforts = [
		{ label: "Low", value: "low" },
		{ label: "High", value: "high" },
	];

	let effort = $state("high");
</script>

<LcdDisplayRow>
	<LcdDisplayLabel>Effort</LcdDisplayLabel>
	<LcdDisplaySelect type="single" items={efforts} bind:value={effort}>
		<LcdDisplaySelectTrigger />
		<LcdDisplaySelectContent>
			{#each efforts as item (item.value)}
				<LcdDisplaySelectItem value={item.value} label={item.label} />
			{/each}
		</LcdDisplaySelectContent>
	</LcdDisplaySelect>
</LcdDisplayRow>

Examples

Inks

The ink is the theme's --primary by default (variant="primary"), so the screen changes with your theme. Switch the theme in the sidebar to see the demo above follow it. For a fixed hardware look, variant also takes amber, green, cyan or red.

Tempo 128.0
Input -12 dB
Sync MIDI
Rec 00:42

For any other colour, set --lcd-display-ink. The glass, the lit, dim and unlit pixels and the glow are mixed from it, in both themes. The select's popup copies the display's variables when it opens, so it takes the same colour.

<LcdDisplay class="[--lcd-display-ink:var(--color-violet-400)]" />

A dot-matrix font

The screen breaks any font into dots with a CSS mask, so it looks like an LCD with the font you already have. For true 5 × 7 characters, load a dot-matrix face such as Doto, point --lcd-display-font at it and turn the mask off with matrix={false}.

Model Opus 5.5
Effort High

This site loads Doto from Fontsource at its heaviest weight, so the dots fill out. The browser fetches the font only on a page that uses it.

src/routes/layout.css
@import "@fontsource/doto/latin-900.css";

@theme {
	--font-doto: "Doto", monospace;
}
<LcdDisplay class="[--lcd-display-font:var(--font-doto)]" matrix={false} />

A level meter

For a level meter on the same screen, add an LCD Meter. It takes the display's ink, appearance and size.

<LcdDisplay>
	<LcdDisplayRow>
		<LcdDisplayLabel>Input</LcdDisplayLabel>
		<LcdDisplayValue>USB Mic</LcdDisplayValue>
	</LcdDisplayRow>
	<LcdDisplaySeparator />
	<LcdMeter aria-label="Input level" source={analyser.meter} />
</LcdDisplay>

Theming

Variable or attributeMeaning
--lcd-display-inkThe display's colour, set by variant. Default: var(--primary)
--lcd-display-litLit pixels. Light: the ink darkened. Dark: the ink
--lcd-display-ink-dimLabels and the separator. Default: the lit pixels at 40%
--lcd-display-ink-unlitThe unlit dots behind the text. Default: the lit pixels at 7%
--lcd-display-glassThe screen. Light: a pale glass in the ink's hue. Dark: near black
--lcd-display-glowThe halo around lit text. Light: a faint shadow. Dark: the ink at 60%
--lcd-display-bezel, --lcd-display-bezel-edgeThe frame's gradient, top to bottom
--lcd-display-fontThe font. Default var(--font-mono)
--lcd-display-pitchThe dot grid's spacing. Default 2px
data-appearanceOn the display and the select's popup: auto, light or dark
data-sizeOn the display, set by size
data-variantOn the display and the select's popup
data-matrixOn the display while the dot mask is on
data-changedOn a value or trigger for a moment after its text changes
data-stateOn LcdDisplayStatus: idle, busy or off. On the select's trigger: open or closed

size sets the text size: sm, default or lg. The rows and the select's popup follow it.

Accessibility

The display is a group. Each select's trigger is a combobox named by its row's LcdDisplayLabel, including one with its own id, and bits-ui handles the keyboard and the listbox semantics. Give a value live to announce its changes to screen readers. The status pixel is decorative. Blinking and the change flicker stop when the user prefers reduced motion.

API reference

LcdDisplay

PropTypeDefault
variant

The ink colour. primary follows the theme's --primary; the others are fixed hardware inks.

"primary" | "amber" | "green" | "cyan" | "red""primary"
appearance

light is a backlit screen with dark pixels, dark is dark glass with glowing ink, auto follows the theme.

"auto" | "light" | "dark""auto"
matrix

Breaks the text into dots on a --lcd-display-pitch grid.

booleantrue
scanlines

Faint horizontal lines over the glass.

booleantrue
size

The text size.

"sm" | "default" | "lg""default"

LcdDisplayValue

PropTypeDefault
live

Announces changes to screen readers with aria-live="polite".

booleanfalse

LcdDisplayStatus

PropTypeDefault
state

idle blinks slowly, busy quickly, off stays unlit.

"idle" | "busy" | "off""idle"

LcdDisplaySelectTrigger

PropTypeDefault
placeholder

Shown while nothing is selected. Children replace the value text.

string—

LcdDisplaySelectContent

Takes bits-ui's Select.Content props, with these defaults.

PropTypeDefault
side "top" | "bottom" | "left" | "right""bottom"
sideOffset number8
align "start" | "center" | "end""end"
alignOffset number0

LcdDisplaySelectItem

Takes bits-ui's Select.Item props. Without children it shows label, or value when there is no label.

Last updated on November 4, 2026