Readable source
// Keep the original source available for review.
const review = {
owner: "Legal",
status: "draft",
};
export default review;Copy and download use the displayed source. Highlighting updates when an equal-length value changes.
Monochrome syntax highlighting with lazy grammars, exact-source copy and download, and a scrollable code region.
const review = { owner: 'Legal', status: 'ready' };// Keep the original source available for review.
const review = {
owner: "Legal",
status: "draft",
};
export default review;Copy and download use the displayed source. Highlighting updates when an equal-length value changes.
npm install @noorddev/vlak-react shiki@^3.19.0
Load the stylesheet once at your app root, then import the components you use.
import "@noorddev/vlak-react/css";
import { HighlightedCode } from "@noorddev/vlak-react/components/highlighted-code";Per-component imports are available at @noorddev/vlak-react/components/highlighted-code.
npx @noorddev/vlak-cli add highlighted-code
Adds the component and its dependencies to components/vlak/. Follow the StyleX setup to compile the source in your application.
npx shadcn add https://vlak.dev/r/highlighted-code.json
Installs the same source through the shadcn CLI.
import { HighlightedCode } from "@noorddev/vlak-react/components/highlighted-code";
<HighlightedCode code={"const ready = true;"} language="typescript" filename="review.ts" lineNumbers />See the integration example to compose these components with your application's model and data.
Optional Shiki renderer with lazy grammars, monochrome tokens, and exact-source copy.
| Prop | Type | Default | Description |
|---|---|---|---|
coderequired | string | ||
language | string | "text" | |
streaming | boolean | false | Keep an unfinished source block readable without repeatedly highlighting it. |
lineNumbers | boolean | false | |
maxHeight | number | 400 | Maximum scrollable source height in pixels. |
copyable | boolean | true | |
downloadable | boolean | true | |
filename | string | "code.txt" | |
onCopyCode | (code: string) => void | Promise<void> |
Also accepts HTMLAttributes<HTMLElement>.
The ref reaches HTMLElement.
| Keys | Does |
|---|---|
| Tab | Reaches copy, download, and the scrollable source region. |
| Enter, Space | Copies or downloads the source through the focused button. |
The same styles are available as CSS. Native HTML provides the static presentation; React or application code supplies state updates and actions.
npm install @noorddev/vlak
import "@noorddev/vlak/css";
<figure class="rs-highlighted-code"><figcaption class="rs-highlighted-code-header"><span class="rs-highlighted-code-language">typescript</span></figcaption><pre class="rs-highlighted-code-pre" tabindex="0" role="group" aria-label="typescript source"><code>const ready = true;</code></pre></figure>