Getting Started
Get bxp-code up and running in your project in under a minute.
Installation
bash
npm install bxp-codebash
pnpm add bxp-codebash
yarn add bxp-codebash
bun add bxp-codeQuick Start
bxp-code ships two components. Import what you need:
tsx
import { BxpCode, BxpCodeTabs } from "bxp-code";
function App() {
return (
<>
{/* Single code block */}
<BxpCode
code={`const greeting = "Hello, World!";
console.log(greeting);`}
lang="javascript"
fileName="hello.js"
theme="dark"
showLineNumbers
/>
{/* Tabbed code blocks */}
<BxpCodeTabs
tabs={[
{ lang: "bash", label: "npm", code: "npm install bxp-code" },
{ lang: "bash", label: "pnpm", code: "pnpm add bxp-code" },
{ lang: "bash", label: "yarn", code: "yarn add bxp-code" },
]}
theme="dark"
/>
</>
);
}jsx
import { BxpCode, BxpCodeTabs } from "bxp-code";
function App() {
return (
<>
<BxpCode
code={`const greeting = "Hello, World!";
console.log(greeting);`}
lang="javascript"
fileName="hello.js"
theme="dark"
showLineNumbers
/>
<BxpCodeTabs
tabs={[
{ lang: "bash", label: "npm", code: "npm install bxp-code" },
{ lang: "bash", label: "pnpm", code: "pnpm add bxp-code" },
{ lang: "bash", label: "yarn", code: "yarn add bxp-code" },
]}
theme="dark"
/>
</>
);
}Requirements
- React 17+ — Compatible with React 17, 18, and 19
- Modern browser — ES2020+ support required
What's Included
| Component | Purpose |
|---|---|
BxpCode | Single code block with highlighting, formatting, copy button, line numbers, sticky headers |
BxpCodeTabs | Multi-tab container for multiple code blocks with shared controls |
Both components support three input methods:
- Code string — Pass code directly via the
codeprop - File upload — Pass a
Fileobject from<input type="file"> - URL fetch — Pass a URL to fetch code from remotely
Supported Languages
bxp-code supports all languages that Shiki supports, including:
TypeScript, JavaScript, Python, Go, Rust, Java, C, C++, C#, HTML, CSS, JSON, YAML, Markdown, SQL, Bash, Ruby, PHP, Swift, Kotlin, and 100+ more.
Next Steps
- Basic Usage — Input methods, formatting, and common patterns
- BxpCode — Detailed guide for single code blocks
- BxpCodeTabs — Detailed guide for multi-tab code blocks
- Themes — Dark, light, and custom color schemes
- API Reference — Full props reference