Code Block
Syntax-highlighted code block with tabs, line highlighting, and copy button
example.ts
1function greet(name: string) {
2 const message = `Hello, ${name}!`;
3 console.log(message);
4}
5
6greet("World");Installation
Dependencies
Examples
Tabs
1import { greet } from "./utils";
2
3greet("World");"use client";
import { CodeBlock } from "@/components/vritti/code-block";
export function CodeBlockTabsExample() {
return (
<div className="flex items-center justify-center p-8">
<div className="w-full max-w-lg">
<CodeBlock
language="typescript"
filename="multi-tab"
tabs={[
{
name: "index.ts",
code: `import { greet } from "./utils";\n\ngreet("World");`,
language: "typescript",
},
{
name: "utils.ts",
code: `export function greet(name: string) {\n console.log(\`Hello, \${name}!\`);\n}`,
language: "typescript",
highlightLines: [2],
},
]}
/>
</div>
</div>
);
}