Code Block

Safe code presentation with lexical highlighting, copying, downloading and disclosure.

Code Block

Default

Copy preserves exact source text and line breaks. Download creates a local text file. The built-in lexical highlighter is intentionally lightweight; the line slot can integrate a dedicated language highlighter. Clipboard failure emits copy-error.

API

PROPS

Property
Type
Description
default
Example
More
code
String
Plain source code. HTML is rendered as literal text.
''
filename
String
Filename shown in the header; also used for code downloads.
—
language
String
Lexical highlighting for js, jsx, ts, tsx, javascript, typescript, python and json. Other languages render as plain text; use the line slot for a full highlighter.
text
line-numbers
Boolean
Show visual line numbers; copied content excludes them.
true
v-model:expanded
Boolean
Controlled disclosure state. Use v-model:expanded to respond to toggles.
true
download
Boolean
Show the local text-file download action.
true

EVENTS

Event
Type
Description
default
Example
More
update:expanded
(value: boolean) => void
Disclosure toggle requested.
—
—
copy
() => void
Clipboard write succeeded.
—
—
copy-error
(error: unknown) => void
Clipboard write failed.
—
—
download
() => void
Download action requested; image results provide their URL.
—
—

SLOTS

Slot
Description
default
Example
More
actions
Customize the action row.
—
—
line
Customize one safely tokenized source line.
—
—

EXPOSES

Method
Type
Description
default
Example
More
copy
() => Promise<void>
Component-owned copy access.
—
—
download
() => void
Component-owned download access.
—
—
Last Updated: 2026-10-28, 06:17:56 UTC
Copied