CodeBlock

Syntax-highlighted codeblock component built on top of react-syntax-highlighter.

Loading...

Installation

npx shadcn@latest add @scrollxui/codeblock 

Usage

import { CodeBlock } from "@/components/ui/codeblock";
<CodeBlock
  language="typescript"
  filename="main.tsx"
  tabs={[
    { name: 'api.ts', code: "fetchData()" },
    { name: 'styles.css', code: ".card { padding: 1rem }", language: 'css' }
  ]}
  breadcrumb={['src', 'components']}
/>

Examples


CodeBlock with Light theme

Loading...

CodeBlock with Multitabs

Loading...

API Reference

CodeBlock

Syntax-highlighted code block with tabs, stats, and file navigation.

Props

PropertyTypeDefaultDescription
languagestringrequired
Language for syntax highlighting. Required if tabs not used.
filenamestringrequired
Displayed filename above the code block.
codestringrequired (if no tabs)
Code string to display. Required if tabs not provided.
tabsArray<{ name: string; code: string; language?: string }>required (if no code)
Array of tabbed code blocks. Each must include a name and code.
highlightLinesnumber[][]
Lines to highlight in the code block.
breadcrumbstring[][]
Optional breadcrumb text shown above filename.
showStatsbooleantrue
Toggles file stats UI (like file size, lines, etc.).
theme"dark" | "light""dark"
Color theme for the code block.

Built withby Ahdeetai.