Skip to content
↑↓ to navigate↵ to openesc to close

Menu

Code Block

Preview

summarize.tstypescriptWriting
1import { generateText } from "ai";

Install

Add it with your package manager, or copy the source manually.

Run it in a project set up with shadcn-vue. The source is copied to components/beui and its dependencies are added to your package.json. Read the shadcn-vue guide

bunx --bun shadcn-vue@latest add @beui-vue/code-block

Import the shared styles once in your application.

TSUsage
import CodeBlock from '@/components/beui/agents/CodeBlock.vue'
import '@/components/beui/styles.css'

API Reference

code
string
Default—
language?
string
Defaulttypescript
filename?
string
Default—
status?
"streaming" | "complete"
Defaultcomplete
showLineNumbers?
boolean
Defaulttrue
highlightLines?
number[]
Default[]
maxHeight?
number
Default280
wrap?
boolean
Default—
copyable?
boolean
Defaulttrue
onCopy?
() => void | Promise<void>
Default—
class?
string
Default—
labels?
Labels

Override any built-in string.

Default—

Composition

Nest generated source inside the response that owns its streaming lifecycle.

StreamingResponse
└── CodeBlock

Note: File Diff explains additions and removals around highlighted code. Tool Result wraps generated code in an execution outcome. Streaming Response embeds highlighted code inside a rich answer.

How it works

Generated code changes faster than a conventional static snippet. The surface must remain readable while lines arrive, preserve syntax structure, and make copying the final result predictable.

Also on React Native. Streaming code with fixed line numbers and wrap.(opens in a new tab)

Updated