Source Code

<div class="ce-window">
  <div class="ce-titlebar">
    <span class="ce-dot r"></span><span class="ce-dot y"></span><span class="ce-dot g"></span>
    <span class="ce-filename">app.tsx</span>
  </div>
  <div class="ce-body">
    <div class="ce-gutter" id="ceGutter"></div>
    <div class="ce-lines" id="ceLines"></div>
  </div>
</div>

Code Editor Skeleton Loader — Syntax-Style Shimmer CSS JS

Code Editor Skeleton Loader · Loaders · Plain HTML, CSS & JS · Live preview

What's included

Features

Randomized per-line indentation for a plausible code shape, not uniform bars
Randomized token count and width per line
Occasional blank lines mimic real source-code breathing room
Tinted token gradients hint at syntax highlighting (keyword, call, string tones)
Real line-number gutter matching the generated line count
Console-style titlebar with window dots and a filename label
Shared shimmer keyframe with per-line animation-delay offsets
Zero dependencies and no syntax-highlighting library required
Easily themeable colors and line count
Drop-in placeholder for any code block, diff view, or IDE panel

About this UI Snippet

Code Editor Skeleton Loader — A Placeholder Shaped Like Real Source Code

Screenshot of the Code Editor Skeleton Loader snippet rendered live

Generic skeleton loaders — flat gray bars of a few fixed widths — work fine for text and cards, but they read as obviously wrong when the real content is source code. Code has line numbers, wildly varied line lengths, indentation that increases and decreases, and color-coded tokens. This snippet builds a skeleton specifically shaped like a code editor: a titlebar with window dots and a filename, a gutter of line numbers, and a body of shimmer "tokens" arranged with randomized indentation and token counts per line.

Randomized, code-shaped line generation

buildLine(i) doesn't just repeat one bar shape. Each line gets a random indent level (0 to 3, multiplied into a margin-left in steps of 18px) and a random count of 1 to 4 token spans, each with its own randomized width between 24px and 92px. Roughly 15% of lines are left blank, mimicking the breathing room real source files have between logical blocks. The result looks like an actual function body rather than a uniform list.

Tinted tokens hint at syntax highlighting

Instead of every shimmer bar sharing one gray gradient, each token is randomly assigned one of a few tinted gradient classes — a muted purple for kw (keyword-like), blue for fn (call-like), and green for str (string-like) — layered under the same moving shimmer animation. The effect reads as a blurred, out-of-focus glimpse of syntax-highlighted code without needing a real syntax highlighter or language grammar.

A believable gutter

The .ce-gutter renders one real line number per generated line, right-aligned in a muted monospace, exactly matching a real code editor's left column — a detail that does a lot of work to sell the illusion, since a gutter is one of the most recognizable features of any code view at a glance.

Console-style chrome

The titlebar's red/yellow/green window dots and monospace filename label match the same convention used by the typewriter status log loader and countless real editors and terminals, so the component is immediately legible as "code" before a single token has rendered.

Why this beats a generic skeleton for code contexts

A generic list-of-bars skeleton over a code preview area creates a visible mismatch the instant real syntax-highlighted code pops in — the shapes don't rhyme. This skeleton's randomized indentation and varied token widths are deliberately irregular in the same way real code is irregular, so the transition into the real editor or code block feels like a continuation rather than a swap.

Customizing it

Adjust LINE_COUNT, the indent step size, or the token width range to match your actual editor's typical line profile. Add more tinted token classes for a richer syntax illusion, or tie LINE_COUNT to the real file's line count once you know it (from a HEAD request or cached metadata) so the skeleton's height doesn't jump when the real content loads. Pair it with a suspense fallback card for the surrounding page shell.

Build with AI

Build, Understand, Optimize, and Extend It With AI

Instead of assuming this is a generic skeleton with extra styling, paste this snippet's HTML, CSS, and JS into an AI coding assistant like Claude and ask it to explain exactly how buildLine() combines randomized indentation, token count, and token width to produce a shape that reads as real source code rather than a uniform list, and why the tinted token classes are layered under the same shimmer keyframe instead of being separate animations. The same assistant can help optimize it — for instance asking whether the random line shapes should be generated once and memoized so they don't visibly reshuffle on every re-render in a component-based framework. It's also useful for extending it: ask it to bias the random indentation to follow more realistic nesting patterns (increasing gradually rather than fully random), add a blinking cursor on one line, or generate the skeleton's line count from a real file's actual line count fetched ahead of time. Treat the code less like a finished artifact and more like a starting point for a conversation.

Prompt to recreate it

Copy this into your AI assistant of choice to build the effect from scratch, or as a jumping-off point for your own variant:

text
Build a skeleton loading placeholder shaped specifically like a code editor in plain HTML, CSS, and JavaScript — no libraries and no real syntax highlighter.

Requirements:
- A window shell with a titlebar containing three colored "traffic light" dots and a monospace filename label, matching the classic code-editor/terminal chrome convention.
- A two-column body: a narrow gutter on the left showing sequential line numbers, and a main area on the right containing one generated placeholder "line" per line number.
- Generate each line's shape randomly and independently in JavaScript: a random indentation level (applied as a left margin in fixed steps, simulating nested code blocks), a random count of 1 to 4 short shimmering token spans per line, each with an independently randomized width, and roughly a 1-in-6 chance for a line to render completely blank to mimic real spacing between code blocks.
- Give the shimmering tokens a couple of different tinted gradient variants (not just plain gray) randomly assigned per token, so the placeholder vaguely suggests syntax-highlighted colors (e.g. a muted purple, blue, and green tone) without performing any real language parsing.
- Use one shared CSS shimmer keyframe animating background-position for all tokens, with a small per-line animation-delay offset so the shimmer doesn't move in perfect unison across every line.
- Keep the whole thing dependency-free — no code-highlighting library, just DOM generation and CSS gradients.

Want to tighten it up first? Run this prompt through the AI Prompt Studio to score it across 8 quality dimensions, catch anti-patterns, and tune the wording for Claude, ChatGPT, or Gemini before you paste it in.

Step by step

How to Use

  1. 1
    Paste HTML, CSS, and JSA code-editor window renders with a titlebar, line-number gutter, and shimmering token lines.
  2. 2
    Observe the varied shapesIndentation, token count, and token width differ per line, with occasional blank lines.
  3. 3
    Notice the tinted tokensMuted purple, blue, and green shimmer tones hint at keywords, calls, and strings.
  4. 4
    Adjust LINE_COUNTChange how many skeleton lines render to match your real editor\u2019s typical height.
  5. 5
    Tune indentation and widthsEdit the randomInt ranges for indent level, token count, and token width.
  6. 6
    Swap in the real editorReplace this component with your real code view (or CodeMirror/Monaco instance) once content loads.

Real-world uses

Common Use Cases

Code snippet and playground loading states
The primary use case — show this while a real syntax-highlighted editor or embed initializes.
Developer tool dashboards
Placeholder for file viewers, diff panels, or log viewers before real content streams in.
Documentation and tutorial sites
A believable placeholder while a live code example loads from a CMS or API.
AI code-generation tools
Show this while an AI assistant is about to stream generated code into an editor pane.
Portfolio and project showcase sites
A polished loading state for embedded code samples on a slower connection.
Related: Typewriter Status Log Loader
See the Typewriter Status Log Loader for a matching console-styled loading pattern.

Got questions?

Frequently Asked Questions

A generic skeleton\u2019s uniform bar widths and lack of indentation create a visible mismatch the instant real syntax-highlighted code appears — the shapes don\u2019t resemble each other. This component randomizes indentation, token count, and token width per line specifically so its irregular shape rhymes with how real code actually looks.

Each token span is randomly assigned one of a few CSS classes (kw, fn, str, or none) that layer a tinted gradient under the same shimmer animation used for the base gray tokens. It is not real syntax analysis — just enough color variation to visually suggest highlighted code at a glance.

Set LINE_COUNT to the actual line count of the file you\u2019re about to load, if you know it ahead of time (e.g. from cached file metadata), so the skeleton\u2019s height doesn\u2019t change once the real editor mounts and causes a layout shift.

Yes. Add another class to the TOKEN_CLASSES array in the JS and a matching .ce-tok.yourclass rule in the CSS with its own tinted linear-gradient — the random selection logic picks up new entries automatically.

No. It has no awareness of any programming language — it is a purely decorative placeholder built from randomized shapes and tinted shimmer gradients meant to be swapped out for your real syntax-highlighted content once it loads.

Yes. Move the line-generation logic (indent level, token count, token widths, blank-line chance) into a function that returns an array of line descriptors computed once via useMemo (or your framework\u2019s equivalent) so the random shapes don\u2019t change on every re-render, then map that array to markup.