Lambda UI
v1.3.4
Stable

CodeBlock

CodeBlock component for displaying syntax-highlighted code with line numbers, copy functionality, and tabs.

Playground

Experiment with all the properties of the CodeBlock component in real time.

Properties
theme

Color theme of the code block.

showLineNumbers

Display line numbers.

buttonCopy

Show copy to clipboard button.

function fibonacci(n) {
  if (n <= 1) return n;
  return fibonacci(n - 1) + fibonacci(n - 2);
}

console.log(fibonacci(10));

Usage

Basic code block with syntax highlighting. Supports multiple programming languages.

import { CodeBlock } from "lambda-ui-components";

const code = `function hello() {
  console.log("Hello, World!");
}`;

export default function App() {
	return (
		<CodeBlock 
			code={code}
			language="javascript"
			theme="dark"
		/>
	);
}

With Highlighted Lines

Highlight specific lines using highlightLines prop. Format: "2,4-6" to highlight lines 2, 4, 5, and 6.

function fibonacci(n) {
  if (n <= 1) return n;
  return fibonacci(n - 1) + fibonacci(n - 2);
}

console.log(fibonacci(10));

With Tabs

Display multiple code snippets with tabs using the tabs prop.

function fibonacci(n) {
	if (n <= 1) return n;
	return fibonacci(n - 1) + fibonacci(n - 2);
}

console.log(fibonacci(10));

CodeBlock Props

Props

Prop
Default
Type
code
""
string
language
"javascript"
string
theme
"dark"
"light" | "dark"
showLineNumbers
false
boolean
buttonCopy
false
boolean
highlightLines
undefined
string
tabs
undefined
CodeTab[]
className
""
string

CodeTab Type

Props

Prop
Default
Type
label
undefined
string
language
undefined
string
code
undefined
string
icon
undefined
ReactNode
The modern React component library.
© 2026 Lambda UI. Made with in Mexico by AletzMan.