0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…
A web component that simulates a terminal: readers type commands, and you decide in JavaScript what each command prints. It reads Vanilla Breeze surface, text, border and radius tokens directly, and the VB stylesheet maps the prompt, cursor and status colors as well.
Or install it from npm and import it in your own script.
npm
npm install @profpowell/terminal-window
Import
import'@profpowell/terminal-window';
Demo
A terminal on a Vanilla Breeze page with two custom commands and the built-in file commands. Click in it and type help, status or ls.
Usage
Add the element and give it a height. It fills the height of its container. The built-in commands are help, clear, echo and history.
A basic terminal
<terminal-windowtitle="deploy"prompt="user@host:~$ "welcome="Type 'help' to list the commands."></terminal-window>
Give it a height
terminal-window {block-size: 24rem;}
Register your own commands in JavaScript. A handler receives the words typed after the command name as an array, and the terminal itself. The string it returns is printed. A handler can be async.
ansi-black, ansi-red, ansi-green, ansi-yellow, ansi-blue, ansi-magenta, ansi-cyan, ansi-white, and a ansi-bright- form of each
The inner elements are also exposed as CSS parts for ::part(), including terminal, header, controls, title, body, output, input-line, prompt and cursor. See the terminal-window documentation for the full detail.
With Vanilla Breeze
A token is a CSS custom property that holds one design value, such as --color-surface. Two things connect the component to Vanilla Breeze tokens.
First, the component itself reads these VB tokens as fallbacks.
VB token
Drives
--color-surface
Terminal background
--color-surface-raised
Header and secondary backgrounds
--color-border
Borders
--color-text
Main text
--color-text-muted
Muted text
--radius-m
Outer corner radius
--radius-s
Radius of buttons and menus
Second, the VB stylesheet contains a token bridge: a rule with the selector terminal-window that sets the component's --terminal-window-* properties from VB tokens. It ships in vanilla-breeze.css and vanilla-breeze-core.css, so there is no extra file to load and no attribute to add. Besides the tokens above, the bridge sets these.
VB token
Set on
--color-success
Prompt, success messages and the fullscreen button
--color-error
Error messages and the close button
--color-warning
The minimize button
--color-info
Info messages
--color-interactive
Cursor and text selection
--color-text, --color-text-muted
Typed commands, and printed output
For each value the order is: the --terminal-window-* property if it is set, then the VB token where the component reads one, then the built-in color for the current mode. The bridge does not set the ANSI colors, the header button colors or the scrollbar colors, so those keep the component's built-in values.
The font is an exception. The component and the bridge both point --terminal-window-font-family at --font-mono, but in version 2.1.0 the element also applies its font-familyattribute, default included, directly to the terminal, and that wins. To use the VB monospace font, set the attribute.
Light or dark is chosen separately. With no mode or themeattribute, the component follows data-mode, data-theme or a dark class on <html> or <body>, then the page's computed color-scheme, then the operating system preference. It updates when these change.
The bridge sits in a cascade layer, so any rule you write outside a layer wins. To change one terminal, set the property on it.
Keyboard: Enter runs the command, the up and down arrows step through the history, Tab completes a command name, and Ctrl+C cancels the current line or skips a typing effect in progress. Escape leaves fullscreen.
The output area has role="log" and is a polite live region, so screen readers announce new lines. Errors and state changes such as "cleared" are announced as well.
The header buttons have ARIA labels. The copy menu is a labeled menu that can be used with the arrow keys.
When the reader has asked for reduced motion, the typing effect is skipped and the cursor stops blinking. The force-animationsattribute overrides this and is meant for testing only.
Use setI18n() to translate the labels and announcements.