BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/prompt-kit/jsx-preview

Jsx Preview

prompt-kit-agents-ui/jsx-preview
FreeComponent

A component for rendering JSX strings as React components, with support for streaming content and automatic tag completion.

Install it

npx shadcn@latest add https://raw.githubusercontent.com/agents-ui/agents-kit/main/public/c/jsx-preview.json

Source

jsx-preview.tsxraw.githubusercontent.com/agents-ui/agents-kit/main/public/c/jsx-preview.json
1import * as React from "react"
2import JsxParser from "react-jsx-parser"
3import type { TProps as JsxParserProps } from "react-jsx-parser"
4
5function matchJsxTag(code: string) {
6 if (code.trim() === "") {
7 return null
8 }
9
10 const tagRegex = /<\/?([a-zA-Z][a-zA-Z0-9]*)\s*([^>]*?)(\/)?>/
11 const match = code.match(tagRegex)
12
13 if (!match || typeof match.index === "undefined") {
14 return null
15 }
16
17 const [fullMatch, tagName, attributes, selfClosing] = match
18
19 const type = selfClosing
20 ? "self-closing"
21 : fullMatch.startsWith("</")
22 ? "closing"
23 : "opening"
24
25 return {
26 tag: fullMatch,
27 tagName,
28 type,
29 attributes: attributes.trim(),
30 startIndex: match.index,
31 endIndex: match.index + fullMatch.length,
32 }
33}
34
35function completeJsxTag(code: string) {
36 const stack: string[] = []
37 let result = ""
38 let currentPosition = 0
39
40 while (currentPosition < code.length) {
41 const match = matchJsxTag(code.slice(currentPosition))
42 if (!match) break
43 const { tagName, type, endIndex } = match
44
45 if (type === "opening") {
46 stack.push(tagName)
47 } else if (type === "closing") {
48 stack.pop()
49 }
50
51 result += code.slice(currentPosition, currentPosition + endIndex)
52 currentPosition += endIndex
53 }
54
55 return (
56 result +
57 stack
58 .reverse()
59 .map((tag) => `</${tag}>`)
60 .join("")
61 )
62}
63
64export type JSXPreviewProps = {
65 jsx: string
66 isStreaming?: boolean
67} & JsxParserProps
68
69function JSXPreview({ jsx, isStreaming = false, ...props }: JSXPreviewProps) {
70 const processedJsx = React.useMemo(
71 () => (isStreaming ? completeJsxTag(jsx) : jsx),
72 [jsx, isStreaming]
73 )
74
75 // Cast JsxParser to any to work around the type incompatibility
76 const Parser = JsxParser as unknown as React.ComponentType<JsxParserProps>
77
78 return <Parser jsx={processedJsx} {...props} />
79}
80
81export { JSXPreview }

What it pulls in

npm packages

  • react-jsx-parser

Files it writes

  • components/prompt-kit/jsx-preview.tsx

Facts

Registry
prompt-kit
Type
registry:ui
Access
Free
Files written
1
Licence
NOASSERTION
In the index
at or before 2026-08-10
Last confirmed
3 days ago

Go to the source

agents-ui.github.io agents-ui/agents-kit on GitHub Raw registry item This item as JSON

More from prompt-kit

All 12 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Chat Containerchat-containerprompt-kitComponentsFree1 dep
Code Blockcode-blockprompt-kitComponentsFree1 dep
File Uploadfile-uploadprompt-kitComponentsFreeno deps
Loaderloaderprompt-kitComponentsFreeno deps
Markdownmarkdownprompt-kitComponentsFree4 deps · 2 files
Messagemessageprompt-kitComponentsFree5 deps · 3 files
Prompt Inputprompt-inputprompt-kitComponentsFreeno deps
Prompt Suggestionprompt-suggestionprompt-kitComponentsFree2 deps

Also from Kynth Studios

Built for the same person as BlockDex

SkillWorks

Claude Code skills and plugins, scored

skillworks.kynth.studio

RuleStack

AGENTS.md gallery and agent-config comparison

rulestack.kynth.studio

ToolDrift

What the AI coding tools changed last night

tooldrift.kynth.studio

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and ToolDrift

part of Toolproof, the measurement layer for AI agent tooling

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and ToolDrift

part of Toolproof, the measurement layer for AI agent tooling

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex

The studio list

One product, taken apart, once a month

Kynth Studios pulls one shipped product open every month — what it does, what it cost to build, what the pipeline behind it looks like, and what the numbers did. One email a month, nothing in between.

Double opt-in — we send one confirmation link and nothing else until you click it.

BlockDex

Built by

Kynth Studios

the studio behind SkillWorks, RuleStack and ToolDrift

part of Toolproof, the measurement layer for AI agent tooling

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product. Changelog

BlockDex