Documentation · Getting Started · API Reference · BxpCodeTabs
- Shiki syntax highlighting — TextMate-grammar-based highlighting for 100+ languages
- Prettier formatting on render — Automatically formats code before display
- Dark & light themes — Built-in themes with easy customization
- Copy to clipboard — One-click copy with visual feedback
- Line numbers — Optional gutter (
showLineNumbers) - Sticky headers — Pin the header/tab bar while scrolling long blocks (
stickyHeader) - Multiple input methods — Render from
code,File, or remoteurl - Tabbed code blocks —
BxpCodeTabsfor multi-snippet containers - TypeScript-first — Full types exported for all public APIs
npm install bxp-codepnpm add bxp-codeyarn add bxp-codeimport { BxpCode } from "bxp-code";
function App() {
return (
<BxpCode
code={`console.log('Hello, World!');`}
lang="javascript"
fileName="hello.js"
theme="dark"
showLineNumbers
/>
);
}import { BxpCodeTabs } from "bxp-code";
function App() {
return (
<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"
/>
);
}Full API documentation lives in
docs/api/index.mdand on the website: https://saqibbedar.github.io/bxp-code/bxp-code
Render a single highlighted + formatted code block.
Input (provide one):
code?: stringfile?: Fileurl?: string
Priority:code>file>url
Common props:
lang?: string(auto-detect)fileName?: string(auto-detect)theme?: "dark" | "light"(default"dark")showHeader?: boolean(defaulttrue)showCopyButton?: boolean(defaulttrue)showLineNumbers?: boolean(defaulttrue)stickyHeader?: boolean(defaultfalse)stickyTop?: number(default0)headerColor?: stringbackgroundColor?: stringclassName?: stringstyle?: CSSPropertiesonError?: (error: Error) => void
Render multiple code blocks inside a tabbed container.
Tabs (BxpCodeTab)
Each tab supports: lang (required), label?, and one of code? / file? / url? (+ optional fileName?).
Common props:
tabs: BxpCodeTab[](required)theme?: "dark" | "light"(default"dark")showLineNumbers?: boolean(defaulttrue)showCopyButton?: boolean(defaulttrue)showHeader?: boolean(defaulttrue)stickyHeader?: boolean(defaultfalse)stickyTop?: number(default0)defaultTab?: number(default0)headerColor?: stringbackgroundColor?: stringborderColor?: stringtabActiveColor?: stringtabActiveTextColor?: stringtabTextColor?: stringtabIndicatorColor?: string(default#e06b74)copyButtonColor?: stringlineNumberColor?: stringclassName?: stringstyle?: CSSPropertiesonError?: (error: Error) => void
Contributions are welcome!
- Please read: CONTRIBUTING.md of Conduct
- Please follow: CODE_OF_CONDUCT.md
MIT — Made by Saqib Bedar