class Signal extends HTMLElement {
connectedCallback() {
this.textContent = "ready";
}
}
customElements.define("x-signal", Signal);
Browser-native code surfaces
MicroLighter Syntax Highlighter Examples
Download Back To CSSScript.Com
A tiny dependency-free syntax highlighter for the web. Add MicroLighter to a page and style code blocks with CSS highlight pseudo-elements.
Drop-in mode
Mark the block. Let the page scan.
A standard pre > code block is highlighted on load. The same runner can rescan markup added later.
const block = document.querySelector("#auto-block");
const liveRanges = CSS.highlights;
document.documentElement.dataset.ready =
liveRanges ? "highlighted" : "unsupported";
Dispatches syntax-highlight after insertion.
Encapsulated controls
Copy, count, and style the surface.
The opt-in element keeps the original code in the light DOM while adding copy controls, line numbers, language precedence, and exposed CSS parts.
def active_scope(name: str) -> str:
return f"scope:{name}"
print(active_scope("function"))
.custom-demo::part(copy-button) {
background: var(--accent);
}
.custom-demo::part(line-numbers) {
color: var(--accent);
}
type Status = "ready" | "busy";
const current: Status = "ready";
Editable rendering
Change the source. Repaint the ranges.
The editor below calls highlightAll() with a scoped root, a custom selector, and optional aliases.
Load on demand
Pick any shipped grammar.
Each option below points at a separate grammar module. The preview requests only the language you choose.