ngx-prompt-kit

Code Block

A bordered code container with syntax highlighting via Shiki. Lazy-loads the highlighter only in the browser.

Examples

With header

A CodeBlockGroup gives the block a filename row and language tag.

greeter.tstypescript
function greet(name: string): string {
  return `Hello, ${name}!`;
}

console.log(greet('world'));

Bare snippet

No header, just the highlighted code.

ng add ngx-prompt-kit
ng generate ngx-prompt-kit:message

Installation

Add the code-block component (and the cn() utility) to your project.

ng generate ngx-prompt-kit:code-block

Component API

PkCodeBlock

PropTypeDefaultDescription
classstring — Extra classes for the bordered container.

PkCodeBlockGroup

PropTypeDefaultDescription
classstring — Extra classes for the header row.

PkCodeBlockCode

PropTypeDefaultDescription
codestring '' The source to highlight.
languagestring 'tsx' Shiki language identifier.
themestring 'github-light' Shiki theme name.
classstring — Extra classes for the code container.