Code Block
Displaying Shiki highlighted code blocks
Installation
npx shadcn@latest add http://fumastudio/com/r/code-block.json"use client";
import { cn } from "@/lib/utils";
import { ShikiHighlighter, Language as ShikiLanguage } from "react-shiki";
type CodeBlockProps = {
code: string;
language: ShikiLanguage;
className?: string;
};
export const CodeBlock = (props: CodeBlockProps) => {
const language = props.language as string;
return (
<ShikiHighlighter
language={language}
theme="github-light-default"
showLanguage={false}
className={cn(
props.className,
"h-full text-xs leading-[1.35rem]",
)}>
{props.code.trim()}
</ShikiHighlighter>
);
};
Usage
// Internal component