The CodeBlock
component is used to display code snippets in a styled block. It includes a header with a language label and a copy-to-clipboard button for convenience.
Install with the following command
npm i @anakin-gbit/code-block@latest
For syntax highlighting you must include a Highlight.js theme manually in your project, eg. in the root layout.tsx
.
import 'highlight.js/styles/github.css'
import { CodeBlock } from '@anakin-gbit/code-block'
<CodeBlock
code={\`const greet = () => {\\n console.log('Hello, world!');\\n}\`}/>`}
language="language-javascript"
/>