InkUI
Components

CodeBlock

Syntax-highlighted code display with line numbers — no external dependencies.

Display code with syntax highlighting using a built-in regex-based tokenizer. Supports 13 languages, line numbers, line highlighting, and titles.

Live Preview
CodeBlock · syntax highlight + line nav
╭─ server.ts ──────────────────────╮
1import express from 'express'
2import path from 'path'
3const app = express()
4const PORT = 3000
5app.listen(PORT)
╰──────────────────────────────────╯
~/my-cli — node v22● running

Installation

npx inkui add code-block

Usage

import { CodeBlock } from './components/ui/code-block';
 
const code = `import express from 'express';
const app = express();
app.listen(3000);`;
 
export default function App() {
  return (
    <CodeBlock
      code={code}
      language="javascript"
      title="server.js"
      highlightLines={[3]}
    />
  );
}

Supported Languages

javascript · typescript · python · json · bash · html · css · rust · go · yaml · markdown · diff · plain

API Reference

PropTypeDefaultDescription
codestringCode string (required)
languageLanguage'plain'Syntax highlighting language
showLineNumbersbooleantrueShow line number gutter
startLinenumber1Starting line number
highlightLinesnumber[][]Lines to highlight (1-indexed)
maxHeightnumberMax visible rows
showBorderbooleantrueShow rounded border
titlestringFilename/title above code
wrapbooleanfalseWrap long lines (false = truncate)
themeInkUIThemedarkThemeColor theme

On this page