Kaleidoscope
Source: RogerSquare/kaleidoscope Category: Project tour
Kaleidoscope — a library of isolated terminal UI demos. Each one shows a specific animation or interaction pattern used by modern TUIs (Claude Code, lazygit, btop). Run one, see how it works, copy the technique.
What it is
Section titled “What it is”A TypeScript CLI app. Browse a menu of ~30 demos; each is a self-contained React component rendered to the terminal via Ink. No “app” to build — this is a reference library you keep open while writing your own TUI.
| Layer | Technology |
|---|---|
| Language | TypeScript 5 |
| Framework | Ink 7 (React for terminals) |
| Runtime | Node 20+ via tsx (no build step) |
| Tests | Vitest + Ink’s ink-testing-library |
| CI | GitHub Actions matrix (Node 20, 22) |
Demo categories
Section titled “Demo categories”- Animations — Claude spinner, progress bars, streaming text, thinking indicators, loading skeletons, gradient text
- Interactive components — selection menus, text input and forms, file trees, tabs, modals
- Layouts — flexbox patterns, split panes, status bars, headers
- Effects — color waves, pulse, shimmer, braille spinners
Each demo lives in its own .tsx file under src/demos/ and exports a single React component.
Running
Section titled “Running”git clone https://github.com/RogerSquare/kaleidoscopecd kaleidoscope && npm installnpm run dev # interactive pickernpm run dev -- claude-spinner # jump straight to one demoNon-obvious design choices
Section titled “Non-obvious design choices”- No build step.
tsxruns TypeScript directly; the repo is usable as-read. Good for a reference project — zero onboarding friction. - Demos are isolated. Each is a pure function returning Ink JSX. They don’t share state or cross-import. Copy-paste is the intended adoption path.
- Tests use
ink-testing-library. Renders to a virtual frame buffer you can assert against. Lets each demo have a unit test that verifies the output shape without fiddling with real terminals.
Gotchas
Section titled “Gotchas”- Ink re-renders on every state update. Unlike browser React, there’s no intermediate DOM — the whole frame re-renders. Memoize aggressively if a demo stutters.
- Color support depends on the host terminal and
FORCE_COLOR. Chalk’s auto-detection sometimes reads zero color support when piped. SetFORCE_COLOR=3if your demo goes monochrome. util.styleTextis Node 20.12+. One test helper uses it; the CI matrix had to drop Node 18 (tracked asKaleidoscope/bug-node18-compat-001).- Terminal resize isn’t free. Ink subscribes to resize events but complex layouts can flicker on small windows. Debounce resize-driven state updates if you see flashing.
See also
Section titled “See also”- projects/cairn — Cairn’s SSH portfolio uses the same Ink primitives for a real app