
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@open-react-hub/code-block
Advanced tools
A feature-rich, customizable code block component for React applications with syntax highlighting, line numbers, and themes
A feature-rich, customizable code block component for React applications with support for syntax highlighting, line numbers, command-line interface simulation, and themes.
npm install @open-react-hub/code-block
# or
yarn add @open-react-hub/code-block
# or
pnpm add @open-react-hub/code-block
This package requires the following peer dependencies:
{
"react": "^18.0.0",
"react-dom": "^18.0.0",
"lucide-react": "^0.263.1",
"prismjs": "^1.29.0"
}
import { CodeBlock } from '@open-react-hub/code-block';
function App() {
const code = `function hello() {
console.log("Hello, World!");
}`;
return (
<CodeBlock
code={code}
language="javascript"
/>
);
}
import { CodeBlock } from '@open-react-hub/code-block';
function Terminal() {
const commands = `$ npm install @open-react-hub/code-block
Installing dependencies...
✓ Done!
$ npm start`;
return (
<CodeBlock
code={commands}
isCommandLine={true}
commandLine={{
user: "dev",
host: "localhost",
path: "~/project"
}}
/>
);
}
| Prop | Type | Default | Description |
|---|---|---|---|
code | string | Required | The code or text content to display |
language | string | 'typescript' | Programming language for syntax highlighting |
showLineNumbers | boolean | true | Show/hide line numbers |
showCopyButton | boolean | true | Show/hide copy button |
showLanguageLabel | boolean | true | Show/hide language label |
theme | 'light' | 'dark' | 'dark' | Color theme |
className | string | '' | Additional CSS classes |
isCommandLine | boolean | false | Enable command-line interface mode |
commandLine | CommandLineConfig | See below | Command-line configuration |
interface CommandLineConfig {
user?: string; // Username in prompt
host?: string; // Hostname in prompt
path?: string; // Current path in prompt
basePrompt?: string; // Custom base prompt
continuationPrompt?: string; // Prompt for continued lines
lines?: LineConfig[]; // Pre-configured lines
}
interface LineConfig {
content: string; // Line content
isOutput?: boolean; // Is this line command output?
isContinuation?: boolean; // Is this a continuation line?
customPrompt?: string; // Custom prompt for this line
}
The component supports syntax highlighting for the following languages out of the box:
The component uses Tailwind CSS classes internally and can be customized using the className prop. The component respects dark/light mode and automatically adjusts its appearance.
<CodeBlock
code={code}
theme="light"
className="my-8 shadow-lg"
/>
<CodeBlock
code="$ ls -la
total 24
drwxr-xr-x 5 user group 160 Jan 14 10:00 ."
isCommandLine={true}
/>
<CodeBlock
code="$ npm start"
isCommandLine={true}
commandLine={{
basePrompt: "➜",
continuationPrompt: "→"
}}
/>
<CodeBlock code={code} language="python" />
<CodeBlock code={code} theme={isDarkMode ? 'dark' : 'light'} />
<CodeBlock
code={commands}
isCommandLine={true}
commandLine={{
user: "dev",
host: "server",
path: "/var/www"
}}
/>
useState and useEffect hooks efficientlyWe welcome contributions! Please see our Contributing Guide for details.
git checkout -b feature/amazing-featuregit commit -m 'Add amazing feature'git push origin feature/amazing-featureMIT © OpenReactHub
FAQs
A feature-rich, customizable code block component for React applications with syntax highlighting, line numbers, and themes
We found that @open-react-hub/code-block demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.