Components · Content
Code
A block of source code with an optional language label and title.
ExamplesLink to this section
export function add(a: number, b: number) {
return a + b;
}Show JSONHide JSON
{
"version": 1,
"root": "code",
"elements": {
"code": {
"type": "Code",
"props": {
"code": "export function add(a: number, b: number) {\n return a + b;\n}",
"language": "ts",
"title": "math.ts"
}
}
}
}PropsLink to this section
Generated from the zod schema the server validates with. Unknown props are ignored with a warning. Any prop can also be a dynamic value such as { "$state": "/path" }; it is checked again once it resolves.
| Prop | Type | Limits and defaults |
|---|---|---|
| coderequired | string | max 20,000 chars |
| language | string | max 40 chars |
| title | string | max 160 chars |
Children and eventsLink to this section
Code is a leaf: it does not show children. Validation warns when a leaf has some; wrap them in a Stack or Card instead.
It emits no events.