amankaushik481

Code Block

Component

About

A zero-dependency syntax-highlighted code block for React with a language tag, optional filename and line numbers, and a copy-to-clipboard button.

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 } from "@/components/ui/code-block";

const demoCode = `import { lumen } from "@/lib/lumen"

// Create an invoice for Northwind and send it
export async function POST(req: Request) {
  const { customerId, amount } = await req.json()
  const invoice = await lumen.invoices.create({
    customerId,
    amount: Math.round(amount * 100), // cents
    dueInDays: 30,
  })
  return Response.json({ id: invoice.id, status: "open" })
}
`;

export default function CodeBlockDemo() {
  return (
    <div className="flex w-full max-w-lg items-center justify-center p-8">
      <CodeBlock filename="route.ts" language="ts" code={demoCode} />
    </div>
  );
}

Dependencies

More by amankaushik481

View all
  • Chip Filter

    Chip Filter

    7
  • Icon Button

    Icon Button

    5
  • Background Boxes

    Background Boxes

    4
  • Emoji Picker

    Emoji Picker

    4
  • Morphing Text

    Morphing Text

    2
  • Typing Text

    Typing Text

    1
  • Treemap Chart

    Treemap Chart

    1
  • Particles

    Particles

    1