Bundui.io

Code Block

Component

About

A syntax-highlighted code block with copy/download buttons, line numbers, diffs, diagnostics, folding and streaming support for docs sites and AI chat interfaces.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Code Block to your project and fits it to your theme.

Code

How Code Block is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

import {
  CodeBlock,
  CodeBlockCopyButton,
  CodeBlockHeader,
  CodeBlockLanguage,
  CodeBlockTitle,
} from "@/components/ui/code-block";

const code = `export function formatPrice(amount: number, currency = "USD") {
  return new Intl.NumberFormat("en-US", {
    style: "currency",
    currency,
  }).format(amount / 100);
}`;

export default function CodeBlockDemo() {
  return (
    <div className="w-full max-w-xl">
      <CodeBlock code={code} language="typescript" showLineNumbers>
        <CodeBlockHeader>
          <CodeBlockTitle>format-price.ts</CodeBlockTitle>
          <CodeBlockLanguage />
          <CodeBlockCopyButton className="ml-auto" />
        </CodeBlockHeader>
      </CodeBlock>
    </div>
  );
}

More by Bundui.io

View all
  • Fluid particles background

    Fluid particles background

    860
  • Floating paths

    Floating paths

    731
  • Text Gradient Scroll

    Text Gradient Scroll

    662
  • Stars

    Stars

    575
  • Image Comparison

    Image Comparison

    430
  • Magnetic Button

    Magnetic Button

    412
  • Marquee Effect

    Marquee Effect

    347
  • Wavy

    Wavy

    232

Explore more

Part of Bundui — browse the full library on 21st.dev.