Vanilla-Components

A collection of lightweight, zero-dependency UI components and demos built with vanilla JavaScript — no frameworks required.

Components

src/vanilla-grid/

A high-performance virtualized data grid web component. Supports virtual scrolling for large datasets, multi-column sorting, column resizing/reordering/freezing/visibility, row selection, infinite scroll, a swappable DataManager pattern, and multiple built-in themes. Available as a plain VanillaGrid class or as the <vn-grid> custom element.

src/vanilla-grid-toolbar/

A state-aware toolbar web component (<vn-grid-toolbar>) bound to a vanilla-grid instance via a grid attribute/property. It observes the grid, exposes a structured state object to author-supplied templates, and forwards user actions (search, export, commands) back to the grid. It has no data of its own and cannot function standalone — it requires a linked grid.

src/vanilla-resize-box/

A resizable container web component (<vn-resize-box>) with a drag handle, configurable min/max constraints, and automatic CSS injection. The drag runs on Pointer Events (mouse, touch and pen on one path), the handle is a role="separator" grip announced to assistive technology but not focusable (resizing is pointer-only), and the whole geometry mirrors under dir="rtl".

src/vanilla-gantt/

A Gantt web component (<vn-gantt>): a task tree shown as bars on a timeline, with summary tasks, milestones, dependency links of four types and five zoom levels. Tasks move by drag, touch hold or keyboard, pushing the successors they would break. Its task list is an embedded <vn-grid> in tree mode, which owns vertical scrolling; the timeline follows the grid's render passes, so both axes stay virtualized at 1M tasks. Data comes from a Gantt DataManager (VanillaGanttStaticDataManager built in). It requires the grid on the page, loaded first, and reads the grid's shared utilities at runtime.

src/vanilla-gantt-toolbar/

A toolbar for the Gantt (<vn-gantt-toolbar gantt="<id>">): a <vn-grid-toolbar> subclass, with all of its templates, items, commands, state and themes, linked to the task grid of the <vn-gantt> its gantt id names. It waits for that Gantt and links its grid once the Gantt is initialized, so a page links it in markup. It requires vanilla-grid-toolbar loaded first; the Gantt may load in any order.

src/vanilla-diagram/

A diagram editor (<vn-diagram>): an SVG canvas of shapes and the connectors between their ports, with a palette (<vn-diagram-palette diagram="<id>">) to drag shapes from in the same bundle. Built-in basic shapes, host-registered symbols and symbol sets, straight, bezier and elbow connectors with editable routes and labels, selection, move, resize, snapping to a grid and to guides, pan and zoom by mouse, touch and keyboard, text edited in place, copy and paste, ten theme-coloured colour slots, SVG and PNG export, and undo and redo of every change. Changes are stored as they happen through a diagram data manager (VanillaDiagramStaticDataManager built in), and a rejected save is reverted. It needs no other component.

src/vanilla-diagram-toolbar/

The diagram's command bar (<vn-diagram-toolbar diagram="<id>">), written in markup as the grid toolbar's is: the standard commands a page wants (undo, redo, zoom, delete, z-order, a colour menu, SVG and PNG export), commands of its own (registerCommand() or the cancelable vn-diagram-toolbar-command), four button styles (primary, secondary, ghost, danger), disabled-when / show-when / hide-when on the diagram's state, and a status text. With no items inside it draws a default bar. It reads the diagram through its public API only, takes its colours from the diagram's theme, and loads in any order with the diagram.

Samples

Fourteen sample frontends demonstrate the components in different integration scenarios. Each folder is named <domain>-<framework>: the eleven *-js apps are plain HTML/CSS/JS, and the remaining three are framework ports of one of them — wikipedia-pages-vue (Vite + Vue 3) mirrors wikipedia-pages-js, github-repos-react (Vite + React) mirrors github-repos-js, and northwind-orders-angular mirrors northwind-orders-js. Each has its own README.

App Data source Highlights
people-cities-js MINT — Measurement INterface Translator, a BFF over OData Two tabs (People / Cities), server-side unit conversion per measurement environment, $metadata-driven headers and precision, EN/IT i18n, theming. Runs as-is — MINT is hosted at https://people-cities-app.mthome.org.
northwind-orders-js Public Northwind OData V4 Single tab, infinite scroll, server-side search, employee-photo decoding, order detail panel.
northwind-customers-js Public Northwind OData V4 Master-detail: three grids chained by selection (customers, their orders, an order's lines), each detail filtered with ODataDataManager.setFilter(); changing a selection empties every grid below it.
github-repos-js GitHub Search REST API Custom DataManager with Link-header (rel="next") continuation-URL pagination.
wikipedia-pages-js MediaWiki Action API Custom DataManager with opaque continue-token pagination, switchable category.
large-dataset-js 1k–2M client-generated rows (selectable) No-backend stress demo: StaticDataManager, mixed column types, multiple-row selection, inline theme and row-count selectors, theme-aware app canvas.
file-system-js 1k–1M client-generated folders and files (selectable) Tree rows: a generated file system shown as a tree from a parent key, opening collapsed; the toolbar's Expand all / Collapse all, a search that keeps every match's folders, sorting within siblings; a click selects a row and a preview pane beside the grid, behind a splitter, shows it. No backend.
project-tasks-js 1k–1M client-generated tasks (selectable) <vn-gantt>: a three-level plan (phases, work packages, tasks) as a task tree and a timeline, summary brackets and milestones, dependency links, moving tasks by drag or keyboard with pushes, five zoom levels, a <vn-gantt-toolbar> linked to the Gantt in markup, with Expand all / Collapse all. No backend.
process-flowchart-js A static order-handling flowchart (plan.json), or a generated plan of 1,000 to 100,000 shapes (?shapes=) <vn-diagram> with a <vn-diagram-palette> and a <vn-diagram-toolbar>: basic shapes and a registered flowchart set (declarative and render-callback symbols) in colour slots, the process in two lanes (containers), elbows routed around shapes, rotation, a snap grid, connecting by ports, undo, redo, z-order, colours, Tidy up (auto-layout) and export from the toolbar, large diagrams drawn only where in view, a screen reader's announcements and outline, a slow data manager with a failing save that the diagram reverts, the diagram's fourteen themes (the grid's seven families, light and dark) and a Ledger theme registered by the app. No backend.
plant-automation-js A static plant control layout (plan.json) <vn-diagram> with three symbol sets the app registers (devices, equipment, interfaces: thirty industrial-automation symbols, each a render callback drawing a card with a pictogram over the node's tag), one colour slot per set, a node added from the palette starting with its symbol's code, the diagram's toolbar, the diagram's fourteen themes (the grid's seven families, light and dark). No backend.
anilist-anime-js AniList GraphQL API GraphQLDataManager: page-based pagination with inline pageInfo.total, server-side sort/search/genre filters, EN/IT i18n, theming.
wikipedia-pages-vue MediaWiki Action API Vite + Vue 3 (TypeScript) port of wikipedia-pages-js; shows the components drop into a framework app.
github-repos-react GitHub Search REST API Vite + React 19 (TypeScript) port of github-repos-js; renders the custom elements directly from JSX with ref-handle wrappers instead of wrapper host elements or directives.
northwind-orders-angular Public Northwind OData V4 Angular (standalone, zoneless, signals) port of northwind-orders-js; built-in ODataDataManager from TypeScript, server-side search with persisted term, employee-photo pipeline, theme-driven expandable search.

Each component also has a step-by-step getting-started guide, docs/<component>/getting-started.md (for example the grid's), built on small standalone example pages in samples/_getting-started/ (its README explains the layout). That folder is not an app: the docs site embeds its pages live.

Building

The project includes a Node.js build script with two modes: minify (default) and minify + obfuscate.

npm install              # install dependencies (first time only)
npm run build            # minify JS/CSS
npm run build:obfuscate  # minify + obfuscate the vanilla-* component JS (string encoding, control-flow
                          # flattening, dead code injection); sample-app JS is still only minified
npm run clean            # remove the dist folder

Output structure:

dist/
  index.html                  # landing page linking to every sample frontend + the docs site (generated)
  landing.css                  # landing page styles, copied from templates/landing/ (generated)
  previews/<component>.svg     # "Get started" card illustrations, copied from templates/landing/previews/
  docs/                        # browsable HTML rendering of docs/**/*.md + the READMEs (generated)
    index.html                 # docs index, grouped by component
    README.html                # rendered root README.md
    vanilla-grid/, vanilla-grid-toolbar/, vanilla-resize-box/, vanilla-gantt/, vanilla-gantt-toolbar/, vanilla-diagram/, vanilla-diagram-toolbar/
      README.html               # rendered component README.md
      getting-started.html      # rendered docs/<component>/getting-started.md, with its live examples
      *.html                    # rendered docs/<component>/*.md
    testing-and-coverage.html   # rendered docs/testing-and-coverage.md
    front-matter.html           # rendered docs/front-matter.md
    samples/<app>/
      README.html               # rendered samples/<app>/README.md — the landing card's "More" target
  vanilla-components/latest/  # standalone component packages (bundle + CSS + themes + .d.ts)
    vanilla-grid/
      vanilla-grid.bundle.js
      vanilla-grid.css
      vanilla-grid.d.ts                        # hand-authored types, copied verbatim
      themes/
    vanilla-grid-toolbar/
      vanilla-grid-toolbar.bundle.js
      vanilla-grid-toolbar.css
      vanilla-grid-toolbar.d.ts
      themes/
    vanilla-resize-box/
      vanilla-resize-box.bundle.js
      vanilla-resize-box.css
      vanilla-resize-box.d.ts
    vanilla-gantt/                             # load after vanilla-grid.bundle.js
      vanilla-gantt.bundle.js
      vanilla-gantt.css
      vanilla-gantt.d.ts                       # imports ../vanilla-grid/vanilla-grid.d.ts
      themes/
    vanilla-gantt-toolbar/                     # load after vanilla-grid-toolbar.bundle.js
      vanilla-gantt-toolbar.bundle.js
      vanilla-gantt-toolbar.d.ts               # imports the grid toolbar's and the Gantt's .d.ts
    vanilla-diagram/                           # <vn-diagram> and <vn-diagram-palette>; needs no other component
      vanilla-diagram.bundle.js
      vanilla-diagram.css
      vanilla-diagram.d.ts
      themes/
    vanilla-diagram-toolbar/                   # <vn-diagram-toolbar> and its items; any order with vanilla-diagram.bundle.js
      vanilla-diagram-toolbar.bundle.js
      vanilla-diagram-toolbar.css
      vanilla-diagram-toolbar.d.ts             # imports the diagram's .d.ts
  samples/
    _common/themes/                            # the app themes the plain-JS apps share
    _getting-started/                          # the getting-started examples the guides embed, one page per step
    <app>/                                     # one folder per plain-JS sample app
      index.html
      app.js
      styles.css
      modules/                                 # (large-dataset-js, file-system-js, project-tasks-js, process-flowchart-js and plant-automation-js have no modules/ dir)
      themes/                                  # app-theme overlays (people-cities-js, northwind-customers-js only)
    wikipedia-pages-vue/, github-repos-react/      # Vite build output (Vue 3 / React)
      index.html
      assets/
      styles.css
      themes/
    northwind-orders-angular/                          # Angular CLI build output
      index.html
      main-*.js
      styles.css
      themes/

build.js also generates dist/index.html, a landing page that links to each component's getting-started guide, every built sample frontend and the docs site. Its Get started section has one card per component that has a guide: a static illustration of the component (templates/landing/previews/<component>.svg, copied to dist/previews/; a guide with no illustration gets no card), the guide's front-matter description, and a Get started ↗ button opening the guide in a new tab. The sample cards follow (card labels derived from each app's <title>, framework badges derived from the app folder's <domain>-<framework> naming convention). Serving dist/ at a web root therefore gives the base URL an index instead of an empty response. Each card carries two links and is not itself clickable: a More ↗ link trailing the description opens that app's README.md — rendered into the docs site at dist/docs/samples/<app>/README.html — and a Show ↗ button in the card's bottom-right corner opens the running app. Both open in a new tab. The page is built by filling templates/landing/index.html (a plain HTML/CSS skeleton with {{TOKEN}} placeholders, styled by templates/landing/landing.css) rather than generating markup inline in build.js, so the page can be edited and previewed like any static page. The sidebar footer shows the package version and the build's date and time in UTC (e.g. 14 September 2026, 09:05 UTC), stamped when build.js runs.

build.js renders docs/**/*.md, the seven component README.md files, the root README.md, and every sample app's README.md to static HTML under dist/docs/ (via marked, a build-only devDependency), so the design docs are browsable from a deploy without cloning the repo. The YAML front matter at the top of each docs/ page (metadata for search and cross-linking, defined in docs/front-matter.md) is stripped before rendering. Sample READMEs land under dist/docs/samples/<app>/ and are listed in the docs index under a samples group (nested ones, like people-cities-js's themes/README.md, are rendered too; READMEs under a sample's node_modules/, dist/, vendor/ or .angular/ folder are not). Markdown links between rendered pages are rewritten to the corresponding .html path (heading anchors use GitHub-style slugs, so existing #anchor links in the docs keep resolving); links into a plain-JS sample app are retargeted to the sibling dist/samples/ tree. Links into src/ that aren't one of the seven component READMEs are degraded to plain text starting with src/... instead of a link, since the deployed repository isn't assumed to be publicly reachable; a link into a framework sample app's own source (wikipedia-pages-vue, github-repos-react, northwind-orders-angular — only their build output is deployed) is degraded the same way, to samples/... text. A paragraph holding only a link to a getting-started example (samples/_getting-started/*.html) renders as a live example instead: the page running in an <iframe>, an "Open in a new tab" link, and the example file's whole source, its component scripts shown as path/to/<component>/<component>.bundle.js; a link naming a missing example fails the build. In the docs index, each component's group lists its README, then its getting-started guide, then the rest by file name. Every rendered page is wrapped in the shared shell templates/docs/page.html (styled by templates/docs/docs.css), which carries the same Vanilla Components favicon as the landing page, so a page opened from a card's More ↗ link shows the same tab icon.

The whole dist/ tree is deployed as one unit. dist/vanilla-components/latest/ is a fixed folder name — not stamped with the package version — so a deploy always exposes the latest build at a stable path; every dist/samples/<app>/ folder is a sibling tree of it, not a copy — each app's index.html has its component <script> paths rewritten from the source tree's ../../src/vanilla-grid/ (etc., relative to samples/<app>/) to ../../vanilla-components/latest/vanilla-grid/ (etc.), so no component files are duplicated per app. The plain-JS apps share their app themes the same way, from dist/samples/_common/themes/ (../_common/themes/ from each app; samples/_common/README.md explains the layout), and the getting-started examples sit in dist/samples/_getting-started/ with the same script-path rewrite. A host that hides folders whose name starts with _ (GitHub Pages' default Jekyll build, unless the site has a .nojekyll file) must be set to serve them. Deploy dist/ as-is; don't move a single app folder out on its own, or its component references will 404.

Hosts that want the multi-file (auto-loading) form of vanilla-grid instead of the single bundle can reference the source tree's per-file scripts directly (vanilla-grid.js + vanilla-grid-element.js, etc.) — that form isn't part of the dist/ build, which always ships the concatenated .bundle.js artifacts. The bundles disable their own auto-loader internally (window.VanillaGridSkipAutoload = true / window.VanillaGridToolbarSkipAutoload = true / window.VanillaGanttSkipAutoload = true / window.VanillaDiagramSkipAutoload = true), so no extra fetches are issued. vanilla-gantt.bundle.js must load after vanilla-grid.bundle.js: the Gantt embeds a <vn-grid> and reads the grid's utilities at runtime. vanilla-gantt-toolbar.bundle.js must load after vanilla-grid-toolbar.bundle.js, whose element it extends. vanilla-diagram.bundle.js holds the diagram and its palette and loads in any order; vanilla-diagram-toolbar.bundle.js loads before or after it. The sample HTML rewrite renames each source <script> tag in place, so a page that lists the grid before the Gantt keeps that order.

Linting

npm run lint          # eslint .
npx eslint <file>     # lint a single file (subsumes node --check)

ESLint (flat config, eslint.config.js) runs two rule tiers: correctness (no-undef, no-unused-vars, no-redeclare, …) and a small style tier that codifies the codebase's existing 4-space/single-quote/LF conventions rather than imposing new ones. Component sources, the sample apps' ES modules, and the Node-side (tests/, build.js) each get their own globals/sourceType block.

Testing

The repo has two complementary suites plus a compile-time type check, and npm test runs all three (type check first, since it's fastest and fails loudest on .d.ts drift):

Setup (first time only)

npm install                          # install all dependencies (includes @playwright/test)
npx playwright install chromium firefox  # browser binaries (Firefox runs a few placement/keyboard/focus specs)

Running tests

npm test                   # all three: type check, then unit, then E2E
npm run test:types         # tsc --noEmit over tests/types/ only (fastest — no browser needed)
npm run test:unit          # Node unit suite only (fast — no browser needed)
npm run test:e2e           # Playwright suite only
npm run test:affected      # type check, unit, and only the E2E specs the branch's changes reach
npm run test:headed        # E2E with a visible browser window
npm run test:ui            # interactive UI mode (pick & re-run tests)
npm run test:report        # open the last HTML report

To run a single unit-test file, pass it explicitly:

node --test tests/node/dom-scheduler.test.js

Note: node --test tests/node (a bare directory) fails with MODULE_NOT_FOUND on current Node versions. Use npm run test:unit (no argument — Node's default discovery finds tests/node/*.test.js), a glob, or an explicit file path.

Affected specs and test progress

npm run test:affected (scripts/run-affected.js) compares the working tree with its merge base on main (--base <ref> for another ref) and runs the type check, the unit suite, and only the Playwright specs that can reach a changed file: a diagram-only branch runs about 30 spec files instead of 220. A change to the grid, the grid toolbar, the resize box, the shared themes, or a file it can't place (build.js, playwright.config.js, …) runs npm test instead. --list prints the selection without running it. How the selection works: docs/testing-and-coverage.md §2.

scripts/run-with-progress.js wraps any test command and keeps a status file, .harness-tmp/test-progress.json, up to date while it runs: the tests done and the time left, the first failure as it happens, and the result at the end. The harness's tests plugin (Claude Code 2.1.330 or later) draws it as a row with a progress bar above the Claude Code prompt, in the CLI, the VS Code extension and the desktop app. How it works: docs/testing-and-coverage.md §2.

node scripts/run-with-progress.js --log suite.log -- npm test
node scripts/run-with-progress.js -- npm run test:affected

Coverage

npm run test:coverage        # unit-suite coverage over src/, printed as a table
npm run test:coverage:e2e    # browser-side V8 coverage from the Playwright suite

test:coverage uses Node's built-in --experimental-test-coverage, scoped to src/** so build.js and the test files themselves stay out of the denominator. It also enforces line/branch/function thresholds (see the script in package.json) and exits non-zero when coverage drops below them. The thresholds sit just under the current numbers so they ratchet upward rather than blocking ordinary work — raise them when coverage improves.

It reports only files a test actually loads — a source file no unit test requires is absent from the table rather than shown as 0%. tests/node/dts-conformance.test.js loads every component source precisely so nothing can hide from the report.

test:coverage:e2e re-runs the Playwright suite with PW_COVERAGE=1, collecting Chromium's V8 coverage per test (via the fixture in tests/playwright/fixtures.js), then aggregates the results with scripts/aggregate-coverage.js. Two adjustments make that run reproducible:

The two percentages use different denominators (Node's line counting vs. the aggregator's statement-line heuristic) and are not addable. Read them per module, not as one repo-wide number — the suites are complementary by design, so a module that looks thin in one is often well covered by the other.

See docs/testing-and-coverage.md for the current per-module numbers, what the instrumented run excludes and why, the threshold ratchet policy, and guidance on writing tests that don't flake.

Continuous integration

.github/workflows/ci.yml runs on every push and pull request: npm run lint, npm run test:types (.d.ts type check), npm run test:coverage (unit suite + thresholds), and npm run build.

The Playwright suite is not run in CI — it needs a Chromium download and several minutes per run. Run it locally before merging:

npm run test:e2e

To narrow the Playwright suite, pass Playwright's own options:

npx playwright test --grep "scroll" --no-deps          # only tests whose title matches
npx playwright test --project chromium                 # one Playwright project only
npx playwright test --project chromium-perf --no-deps  # only the performance specs

The performance specs (PERF_SPECS in playwright.config.js) run in the chromium-perf project, after every other project has finished and one at a time, so other workers don't compete with them for CPU. That project depends on all the others, and a filter doesn't narrow dependencies: without --no-deps, a filtered run that matches a performance spec runs the whole suite first.

The Playwright config (playwright.config.js) automatically starts a static server for people-cities-js on port 4173 before tests run, so no manual server setup is needed.

Recording new tests

Use the helper scripts to launch Playwright Codegen — a record-and-playback tool that captures your browser interactions and generates test code:

PowerShell (scripts/record-test.ps1):

./scripts/record-test.ps1                        # interactive prompt
./scripts/record-test.ps1 -TestName "my-test"    # pass name directly

Or use the npm shortcut to open Codegen directly (save the output manually):

npm run test:record

The helper starts a static server, opens the browser with the Playwright inspector, and saves the recorded test into tests/playwright/. You should then review the generated file and add proper assertions.

Test structure

tests/
  types/                           # tsc --noEmit smoke tests (npm run test:types)
    vanilla-grid.dts-typecheck.ts         # exercises vanilla-grid.d.ts
    vanilla-grid-toolbar.dts-typecheck.ts # exercises vanilla-grid-toolbar.d.ts
    vanilla-resize-box.dts-typecheck.ts   # exercises vanilla-resize-box.d.ts
    vanilla-gantt.dts-typecheck.ts        # exercises vanilla-gantt.d.ts
    vanilla-gantt-toolbar.dts-typecheck.ts # exercises vanilla-gantt-toolbar.d.ts
    vanilla-diagram.dts-typecheck.ts      # exercises vanilla-diagram.d.ts
    vanilla-diagram-toolbar.dts-typecheck.ts # exercises vanilla-diagram-toolbar.d.ts
  playwright/                     # Playwright E2E specs (npm run test:e2e)
    _helpers.js                   # shared boot/row-injection helpers
    fixtures.js                   # test/expect re-export + PW_COVERAGE fixture
    fixtures/                     # standalone HTML pages for specs that need
                                  # a page of their own rather than a sample app
    scrolling-performance.spec.js # e.g. grid scroll performance
    ...                           # (add more spec files here)
  node/                           # Node built-in (node:test) unit suite
    _helpers.js                   # shared helpers (waitFor)             (npm run test:unit)
    dom-scheduler.test.js         # e.g. scheduler unit tests
    dts-conformance.test.js       # runtime name check of the .d.ts files
    ...                           # (add more *.test.js files here)
scripts/
  aggregate-coverage.js           # aggregates browser V8 coverage into a table
  run-e2e-coverage.js             # runs the E2E suite with coverage enabled
  record-test.ps1                 # PowerShell recording helper
  run-affected.js                 # runs only the tests a branch's changes reach (npm run test:affected)
  run-with-progress.js            # runs a test command, keeping a status file of its progress
playwright.config.js              # Playwright configuration
tsconfig.json                     # tsc config for tests/types/ (npm run test:types)

All three run by default. npm test runs the type check first (fast, fails early), then the unit suite, then the Playwright suite. Each can be run alone with npm run test:types / npm run test:unit / npm run test:e2e.

Writing a spec: import test / expect from ./fixtures.js, not from @playwright/test — the fixture module re-exports both and adds the opt-in coverage collector. A spec that imports @playwright/test directly still works, but contributes nothing to npm run test:coverage:e2e.

Waiting in a unit test: use waitFor(predicate) from tests/node/_helpers.js rather than a fixed setTimeout sleep. A fixed sleep ties the result to machine speed, and the suite runs its files concurrently — that is how the one historical flake in this suite happened.