nessra uinessra ui

Display code with syntax highlighting powered by Shiki.

Loading...
import { CodeBlock } from "@/components/ui/code-block"

const code = `import { Button } from "@/components/ui/button"

Installation

pnpmnpmyarnbun
pnpm dlx shadcn@latest add https://nessra-ui.vercel.app/r/code-block.json

Usage

import { CodeBlock } from "@/components/ui/code-block"
<CodeBlock code={`console.log("Hello, World!")`} language="javascript" />

Examples

With Line Numbers

Enable line numbers with the showLineNumbers prop.

Loading...
import { CodeBlock } from "@/components/ui/code-block"

const code = `function fibonacci(n: number): number {

Simple Command

Display a simple command or snippet.

Loading...
import { CodeBlock } from "@/components/ui/code-block"

const code = `npm install nessra-ui`

API Reference

CodeBlock

PropTypeDefaultDescription
codestring-The code to display
languagestringplaintextLanguage for highlighting (e.g., "tsx")
showLineNumbersbooleanfalseShow line numbers
showCopyButtonbooleantrueShow copy button
maxHeightstring | number400pxMaximum height with scroll

CodeBlock uses Shiki for syntax highlighting and automatically adapts to light/dark mode.