interface

CodeBlock

Syntax-highlighted code on the Onda glass surface, revealed line-by-line. Deterministic dependency-free tokenizer (no async at render). Keywords carry the one earned accent; everything else stays neutral. The reference for the interface category.

$ npx ondajs add code-block

CodeBlock

Syntax-highlighted code on the Onda glass surface (Surface primitive), revealed line-by-line via the useStaggeredEntrance hook. Highlighting is a deterministic, dependency-free tokenizer that runs in render — no async, no Shiki at frame time — so frame N is always reproducible (§1). Keywords carry the one earned accent (--onda-accent); strings, comments, and numbers use restrained neutral steps.

This is the reference implementation for the interface category.

Props

PropTypeDefaultNotes
codestringsampleSource; newlines become reveal-able lines.
titlestring"onda.ts"Filename in the title bar.
chromebooleantruemacOS-style window chrome.
revealLinesbooleantrueReveal lines one-by-one.
delaynumber0Frames before the first line.
lineDelaynumber3Frames between line reveals.
fontFamilystringmonospace stackCode needs real monospace for alignment.
fontSizenumber48Code font size (sized for video, not screen UI).
widthnumber?autoSurface width.
textColor / keywordColor / stringColor / commentColor / numberColorstringtoken defaultsTunable palette.
placementregion or {x,y,anchor}Canvas placement.

The default tokenizer is tuned for JS/TS. For other languages it falls back gracefully (keywords/strings/comments/numbers only).

Usage

TSX
import { CodeBlock } from './components/onda/code-block/CodeBlock';

export const CodeScene = () => (
  <CodeBlock
    code={`export const onda = motion('identity');\nawait onda.render();`}
    title="render.ts"
    placement="center"
  />
);