package
Display text that stays at the bottom of the console.
npm install console-static-textGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Estimated unpacked size across 1 packages.
160.8 kB
Includes dependencies.
console-static-textFor the Rust crate, go to console_static_text.
Install:
# jsr
deno add jsr:@david/console-static-text
# npm
npm install console-static-textLibrary for displaying text that should stay at the bottom of the console. This measures words to handle wrapping and has some console resizing support. Example use might be for displaying progress bars or rendering selections.
import { staticText } from "console-static-text";
import { delay } from "@std/async/delay";
using scope = staticText.createScope();
scope.setText([
"Some text",
"Some very long text. ".repeat(10),
() => `Time is: ${new Date()}`,
(consoleSize) => `Console size: ${consoleSize.rows}, ${consoleSize.columns}`,
() => {
// or deferred and multiple lines.
return [
"Line 1",
You can start a render interval for the duration of some work:
import { renderInterval, staticText } from "console-static-text";
import { delay } from "@std/async/delay";
// defaults to 60
renderInterval.intervalMs = 30;
async function download() {
using _renderScope = renderInterval.start(); // updates the displayed text periodically
// make sure these are after so it's disposed before the render scope
using timeScope = staticText.createScope();
using downloadScope = staticText.createScope();
const startTime = Date.now();
timeScope.setText(() => `It's been ${Date.now
Note this won't render if there's any blocking synchronous work. To do that, you
must force a refresh via staticText.refresh().
Hanging indentation is possible by providing TextItem objects.
import { staticText } from "console-static-text";
using scope = staticText.createScope();
scope.setText([{
text: "Some non-hanging text.",
}, {
text: "Some long text that will wrap at a certain width.",
hangingIndent: 4,
}]);
staticText.refresh(); // draw to console windowThis is useful when implementing something like a selection UI where you want text to wrap with hanging indentation.
By default, the library has two exports that are singletons around
stderr—staticText and renderInterval. These are an instance of
StaticTextContainer and RenderInterval respectively. New instances of these
classes can be created and used instead of the singletons if you wish.