npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@svelterm/core

v0.33.0

Published

Svelte 5 components rendered to the terminal with real CSS

Downloads

110

Readme

svelterm

Svelte 5 components rendered to the terminal with real CSS.

Write standard Svelte components with <style> blocks. They render in the terminal with ANSI escape sequences — flexbox layout, scoped styles, CSS variables, pseudo-classes, all on a cell grid.

Try it: live playground and docs at svelterm.dev, or pipe a demo straight into a real terminal:

curl -fsSL https://svelterm.dev/run/counter.mjs | node --input-type=module -

svelterm is largely LLM-written — designed and directed by a human, with most of the code produced in pair-programming sessions with Claude, test-driven and reviewed as it landed. If that's not your thing, there are plenty of artisanal, hand-typed frameworks out there.

Early release. Svelterm requires an unmerged Svelte branch (svelte-custom-renderer by @paoloricciuti) that adds the custom renderer API. It is not usable with mainline Svelte yet.

Example

<script>
    let count = $state(0)
</script>

<style>
    .counter {
        display: flex;
        flex-direction: column;
        border: rounded;
        border-color: cyan;
        padding: 1cell;
        gap: 1cell;
    }

    .value {
        color: yellow;
        font-weight: bold;
    }

    button:focus {
        color: cyan;
        font-weight: bold;
    }
</style>

<div class="counter">
    <span>Count: <span class="value">{count}</span></span>
    <button onclick={() => count++}>Increment</button>
    <button onclick={() => count--}>Decrement</button>
</div>
import { run } from '@svelterm/core/app'
import { readFileSync } from 'fs'
import App from './App.svelte'

const css = readFileSync('./main.css', 'utf-8')
run(App, { css })

Dual-target components

The same Svelte component can render in both terminal and browser. Terminal-specific CSS values (border: rounded, 1cell, opacity: dim) are naturally ignored by browsers — they're invalid CSS. Browser-specific rules go in @media (display-mode: screen).

<style>
    .greeting {
        border: rounded;
        border-color: cyan;
        padding: 1cell;
    }

    @media (display-mode: screen) {
        .greeting {
            border: 2px solid #00b4d8;
            border-radius: 8px;
            padding: 1rem;
        }
    }
</style>

To build for each target, use separate Vite configs — one with customRenderer: '@svelterm/core' for terminal, one without for browser. The component source is the same.

What's different in terminal CSS

Standard CSS works as expected. These are the terminal-specific additions:

| Feature | Terminal | Browser | |---------|----------|---------| | Borders | single, double, rounded, heavy (box-drawing characters) | Ignored (invalid values) | | Units | cell — one monospace character position | Ignored (unknown unit) | | Opacity | dim — terminal dim attribute | Ignored (invalid value) | | Colors | ANSI names, 256-color, truecolor hex, CSS named colors | Standard CSS colors | | Media | @media (display-mode: terminal) | @media (display-mode: screen) |

Features

  • CSS engine — selectors (attribute operators, structural/state pseudo-classes, ::before/::after), specificity, cascade, inheritance, scoped styles, var(), calc(), @media, @container, @supports, @keyframes
  • Flexbox layoutflex-direction, justify-content, align-items, flex-grow, flex-shrink, gap, flex-wrap
  • CSS grid — column and row templates with fr/repeat()/minmax(), grid-column/grid-row placement and spans, grid-template-areas with named grid-area
  • CSS tablesdisplay: table* including inline-table, sections and captions, colspan/rowspan, column sizing, vertical-align, border-collapse with shared box-drawing grid lines, anonymous boxes
  • Animations & transitions@keyframes with RGB colour interpolation and cell-stepped length animation, transition on style changes, easing functions
  • Terminal rendering — ANSI colors (16, 256, truecolor), borders, text styles, differential output
  • Input — keyboard events, mouse click and scroll, focus management with Tab/Shift+Tab, :focus and :hover pseudo-classes
  • Form controls<input>/<textarea> editing, checkboxes and radios, cycling <select>, <progress>/<meter> bars, <details>/<summary>
  • Incremental updates — mutation tracking classifies changes as paint-only, style-resolve, or layout to avoid full recomputation
  • Color scheme — automatic prefers-color-scheme detection via terminal queries

Browser compatibility

Any HTML/CSS feature with a sensible cell-grid meaning works as a browser author expects; pixel-derived features are dropped silently and targeted per mode with @media (display-mode: terminal | browser). The manual lives in docs/getting started, terminal CSS, layout, selectors, elements & input, motion, compatibility, terminal support, inline mode — with the one-page support matrix in docs/reference.md and the design rationale in DESIGN-browser-compat.md.

Prerequisites

Svelterm requires the experimental custom renderer API from the svelte-custom-renderer branch by @paoloricciuti. Until sveltejs/svelte#18505 lands (it exposes mount/unmount from svelte/renderer, which svelterm needs on Node), clone the branch from the svelterm fork, which tracks upstream plus that fix:

# Clone the branch
git clone -b svelte-custom-renderer https://github.com/tomyan/svelte.git svelte-fork
cd svelte-fork
pnpm install
pnpm -C packages/svelte build

Then reference it in your project's package.json:

{
    "peerDependencies": {
        "svelte": "file:../svelte-fork/packages/svelte"
    }
}

Setup

Scaffold a project with the CLI (the Svelte fork above must be a sibling directory, or adjust the svelte path in the generated package.json):

npx @svelterm/core init my-app
cd my-app && npm install
npm run dev    # vite dev server (terminal 1)
npm run app    # the app, hot-reloading, in this terminal (terminal 2)
npm run build  # → dist/app.mjs — self-contained, runs with plain node

console.log output from the app streams to the vite terminal, like a browser console. See docs/getting-started.md for manual setup and dual-target configuration.

API

run(component, options?)

Start an interactive terminal application.

import { run } from '@svelterm/core/app'

const stop = run(App, {
    css,                    // Extracted CSS string
    fullscreen: true,       // Use alternate screen buffer (default: true)
    mouse: true,            // Enable mouse input (default: true)
    props: { name: 'world' },
})

// Call stop() to shut down and restore terminal

Returns a function that stops the application, unmounts the component, and restores the terminal.

License

MIT