Code Snippet, animated React component
A code block for developer pages. A macOS-style header with the language in quiet monospace (click it to switch) and a small Copy button that morphs into a tick. Real token-level highlighting for JS, TS, Python, Bash and JSON with no highlighter library, dark and light themes, optional line numbers, and lines that roll in one after another.
- Pro
- Cards
- Spring
Play with it
Move the controls and watch it change. Copy code gives you a snippet with only the props you changed.
const fetchUser = async (id) ⇒ { try { const res = await fetch(`/api/users/${id}`); if (!res.ok) throw new Error("Not found"); return await res.json(); } catch (error) { console.error("Request failed:", error); return null; }}; fetchUser(42).then((user) ⇒ console.log(user.name));Props
| Prop | Type | Default | What it does |
|---|---|---|---|
| initial | "js" | "ts" | "python" | "bash" | "json" | "js" | Language shown first. |
| theme | "dark" | "light" | "dark" | Colour theme of the block. |
| lineNumbers | boolean | true | Shows line numbers. |
| controls | boolean | true | Shows the chip row for language, theme and line numbers under the block. |
| autoplay | boolean | false | Tours the languages every few seconds until someone touches it. Pauses off screen. |
| className | string | — | Extra classes for the wrapper. |