Code Block
Code blocks built for AI answers. Syntax highlighting that keeps up with streaming, copy, download and wrap, line numbers and highlighted lines, diffs with accept and reject, and a terminal for commands.
Add the Pro registry to components.json
components.json Add your token
Create a token on your account page and put it in
.env.localasHEXTAUI_PRO_TOKEN.Add the block
pnpm dlx shadcn@latest add @hextaui-pro/code-block
In Markdown with Streamdown
Register CodeFence as a renderer. It reads the language and fence settings like title="app/page.tsx", {2,4-6} and showLineNumbers, and keeps highlighting while the fence is still streaming.
Reviewing a change
Show a proposed edit as a diff and let the reader accept or reject it, with ⌘↵ and ⌘⌫ while the block has focus.
On its own
Pass the code and language directly, for example when a tool call returns file contents.
Code
9 files, added to components/blocks/code-block.