Source shown honestly: mono, copyable, highlighted.
1 2 3 4 5 6 7 8 9 10 11import { useState } from "react"; // Optimistic like — render the result first function Like({ id }) { const [liked, setLiked] = useState(false); return ( <button aria-pressed={liked} onClick={() => setLiked(!liked)}> {liked ? "★" : "☆"} </button> ); }
1 2 3 4 5 6 7 8 9 10 11import { useState } from "react"; // Optimistic like — render the result first function Like({ id }) { const [liked, setLiked] = useState(false); return ( <button aria-pressed={liked} onClick={() => setLiked(!liked)}> {liked ? "★" : "☆"} </button> ); }
| Prop | Type | Notes |
|---|---|---|
| language | string | Shown uppercase in the header; drives token classes |
| children | string | The source; whitespace preserved verbatim |
| showLineNumbers | boolean | Gutter of right-aligned, unselectable line numbers |
| wrap | boolean | Soft-wrap long lines instead of scrolling |
| onCopy | (text) => void | Fires after the clipboard write resolves |
| Event / Key | Result |
|---|---|
| Click Copy | Writes to clipboard, flips label to “Copied ✓” for 2s |
| Enter · Space | Activates the focused Copy button |
| ⌘/Ctrl + C | Native selection copy still works — the button is a shortcut |
Copy is an optimistic gesture: the label flips to success the instant you click, then the clipboard write happens. If it fails, the label rolls back honestly. Try it —
$ npm install @optimistic/ui
# 54 components, one warm accent
$ optimistic sync --tokens
✓ reconciled · 142ms.o-btn {
background: #ff7a00; /* the one warm accent */
color: #1a0e04;
border-radius: 8px;
height: 40px;
}
.o-btn:hover { filter: brightness(1.05); }$ npm install @optimistic/ui
# 54 components, one warm accent
$ optimistic sync --tokens
✓ reconciled · 142msLabel the language and offer copy. Small courtesies developers feel every time.
Don't use a full block for an inline token — reach for Keyboard Input or plain code text.
Keep highlighting restrained — one warm accent for keywords, greys for the rest.
Don't rainbow every token. Noise buries the one thing worth noticing.
import { useState } from "react";
// Optimistic like — render the result first
function Like({ id }) {
const [liked, setLiked] = useState(false);
return (
<button aria-pressed={liked} onClick={() => setLiked(!liked)}>
{liked ? "★" : "☆"}
</button>
);
}A component example in a guide, copyable in one click.
.o-btn {
background: #ff7a00; /* the one warm accent */
color: #1a0e04;
border-radius: 8px;
height: 40px;
}
.o-btn:hover { filter: brightness(1.05); }CSS custom properties shown honestly, verbatim.
$ npm install @optimistic/ui
# 54 components, one warm accent
$ optimistic sync --tokens
✓ reconciled · 142msA shell one-liner in a getting-started page.
| Token | Value | Role |
|---|---|---|
| --code-bg | #0D0E11 | Body surface |
| --code-head-bg | #121317 | Header bar |
| --code-border | #1E1E1E | The site hairline |
| --code-radius | 10px | Corner radius |
| --code-font | 0.78rem / 1.75 | Mono body size and leading |
| --cb-kw | #FF7A00 | Keywords & tags — the one warm role |
| --cb-str | #8FBFA8 | Strings — the single cool hue |
| --cb-cmt | #5B6069 | Comments, grey italic |
<div class="o-code">
<div class="o-code__head">
<span class="o-code__lang">tsx</span>
<button class="o-code__copy" onclick="copyBlock(this)">Copy</button>
</div>
<pre class="o-code__body"><code><span class="cb-kw">const</span> x = <span class="cb-num">42</span>;</code></pre>
</div>