For the complete documentation index, see llms.txt. Markdown variants are available by appending .md to any URL or sending an Accept: text/markdown header. An agent skill is available at /.well-known/agent-skills/site-skill.md.
0
Sponsor

Code Block

A syntax-highlighted code block with filename, line numbers, and copy button.

hello.ts
function greet(name: string): string {
  return "Hello, " + name + "!";
}

console.log(greet("World"));

Installation

$ pnpm dlx shadcn@latest add @slidecn/code-block

Usage

import CodeBlock from "@/components/slides/code-block";
 
function MyPresentation() {
  return (
    <Deck>
      <CodeBlock
        language="python"
        lineNumbers="1|3-5"
        filename="main.py"
        showCopy={true}
      >
        {`def hello():
    print("Hello, world!")`}
      </CodeBlock>
    </Deck>
  );
}

API Reference

CodeBlock

PropTypeDefaultDescription
languagestringrequiredCode language
childrenstringrequiredCode content
lineNumbersboolean | string-Show or configure line numbers
filenamestring-Display filename in header
showCopybooleantrueShow copy button
autoAnimateIdstring-Auto-animate data ID
startFromnumber-Starting line number
trimbooleantrueTrim whitespace