128
A code viewer with file tabs, hand-rolled syntax colour, click-to-highlight lines, a diff view that works out the +/− itself, wrap and copy, and long files that fold behind a fade.
akacode block·syntax highlighting·code viewer
Run this in any project set up for the shadcn CLI. It copies the Code Block source into your components folder, so the code is yours to change.
npx shadcn@latest add https://devl.dev/r/code-block.jsonImport it and render it. Every prop has a typed default, so it works straight away, and you pass your own data when you’re ready.
import { CodeBlock } from "@/components/code-block";
export default function Page() {
return <CodeBlock />;
}A free React component in the Dev Tools collection, written in TypeScript with Tailwind CSS on coss ui. MIT licensed.
Read from the Code Block source. Everything is optional unless it says required.
| Prop | Type | Default |
|---|---|---|
| filesrequired | CodeFile[] | — |
| defaultFile | string | — |
| defaultDiff | boolean | false |
| defaultWrap | boolean | false |
| maxLines | number | 14 |
| className | string | — |