Code Block
A lightweight React component based on SHIKI that provides syntax highlighting using Shiki with built-in copy functionality. Perfect for displaying code snippets in documentation, blogs, and developer tools with dark/light theme support.
A lightweight React component based on SHIKI that provides syntax highlighting using Shiki with built-in copy functionality. Perfect for displaying code snippets in documentation, blogs, and developer tools with dark/light theme support.
npx uilayouts@latest add shiki-code
import { ShikiCode } from '@/components/ui/shiki-code';
export default function MyComponent() {
const code = `function hello() {
console.log('Hello, World!');
}`;
return (
<ShikiCode
code={code}
lang="javascript"
className="my-4"
/>
);
}
| Prop | Type | Default | Description |
|---|---|---|---|
code | string | Required | The code string to highlight |
lang | string | 'tsx' | Programming language for syntax highlighting |
className | string | undefined | Additional CSS classes for styling |
The component supports all languages that Shiki supports, including:
javascript, typescript, tsx, jsxpython, java, c, cpp, csharphtml, css, scss, sassjson, yaml, toml, xmlmarkdown, mdxbash, shell, powershell