Preview
Loading preview…
root = Code("const res = await fetch(\"/api/chat\", { method: \"POST\" });\nconst text = await res.text();", lang:"ts", title:"client.ts", numbered)Signature
This is the line a model reads in the system prompt.
Code(code, lang:str, title:str, numbered)- Group: Content
- Children: No
- Positional arguments:
code(a trailing?means it may be left out)
Props
| Prop | Type | How to write it | Notes |
|---|---|---|---|
code |
string | positional, required | |
lang |
string | named: lang:… |
|
title |
string | named: title:… |
|
numbered |
flag | bare word: numbered |
Use your own component
Keep the name and schema, swap what is drawn. The prompt and the model’s output do not change.
import { ui } from "@gistui/react/ui";
const lib = ui.extend({ Code: MyCode });
<GistUI library={lib} stream={response.body} />;<GistUI :source="answer" :components="{ Code: MyCode }" /><GistUI source={answer} components={{ Code: MyCode }} /><GistUI source={answer()} components={{ Code: MyCode }} />import { ui } from "@gistui/vanilla/ui";
const lib = ui.extend({ Code: (ctx) => ({ el: myElement(ctx) }) });See Custom components for the full contract. Style hook: [data-gistui="Code"].