Components / AI Chat Interfaces
AI Markdown Renderer
A rich markdown renderer for AI responses supporting code blocks with syntax highlighting, tables, lists, and inline formatting.
Components / AI Chat Interfaces
A rich markdown renderer for AI responses supporting code blocks with syntax highlighting, tables, lists, and inline formatting.
This is a rich AI response with bold, italic, and inline code.
function greet(name: string) {
return `Hello, ${name}!`;
}
console.log(greet("World"));
| Feature | Supported |
|---|---|
| Code blocks | ✅ |
| Tables | ✅ |
| Lists | ✅ |
Add the necessary Shadcn UI primitives.
npx shadcn-ui@latest add cardimport { Card, CardContent } from "@/components/ui/card";
interface AIMessageMarkdown01Props {
htmlContent?: string; // HTML string content for AI response
}
export default function AIMessageMarkdown01({
htmlContent = `
<h1>Hello from ChatGPT</h1>
<p>This is a rich AI response with <strong>bold</strong>, <em>italic</em>, and <code>inline code</code>.</p>
<h2>Code Example</h2>
<pre><code class="language-ts">
function greet(name: string) {
return \`Hello, \${name}!\`;
}
console.log(greet("World"));
</code></pre>
<h2>Features</h2>
<ul>
<li>Lists support</li>
<li>Tables support</li>
<li>Links: <a href="https://ui.shadcn.com" target="_blank">ShadCN UI</a></li>
</ul>
<table>
<thead>
<tr>
<th>Feature</th>
<th>Supported</th>
</tr>
</thead>
<tbody>
<tr>
<td>Code blocks</td>
<td>✅</td>
</tr>
<tr>
<td>Tables</td>
<td>✅</td>
</tr>
<tr>
<td>Lists</td>
<td>✅</td>
</tr>
</tbody>
</table>
`,
}: AIMessageMarkdown01Props) {
return (
<Card className="border-0 w-full">
<CardContent className="p-0">
<div
className="prose max-w-full dark:prose-invert"
dangerouslySetInnerHTML={{ __html: htmlContent }}
/>
</CardContent>
</Card>
);
} import { Card, CardContent } from "@/components/ui/card";
interface AIMessageMarkdown01Props {
htmlContent?: string; // HTML string content for AI response
}
export default function AIMessageMarkdown01({
htmlContent = `
<h1>Hello from ChatGPT</h1>
<p>This is a rich AI response with <strong>bold</strong>, <em>italic</em>, and <code>inline code</code>.</p>
<h2>Code Example</h2>
<pre><code class="language-ts">
function greet(name: string) {
return \`Hello, \${name}!\`;
}
console.log(greet("World"));
</code></pre>
<h2>Features</h2>
<ul>
<li>Lists support</li>
<li>Tables support</li>
<li>Links: <a href="https://ui.shadcn.com" target="_blank">ShadCN UI</a></li>
</ul>
<table>
<thead>
<tr>
<th>Feature</th>
<th>Supported</th>
</tr>
</thead>
<tbody>
<tr>
<td>Code blocks</td>
<td>✅</td>
</tr>
<tr>
<td>Tables</td>
<td>✅</td>
</tr>
<tr>
<td>Lists</td>
<td>✅</td>
</tr>
</tbody>
</table>
`,
}: AIMessageMarkdown01Props) {
return (
<Card className="border-0 w-full">
<CardContent className="p-0">
<div
className="prose max-w-full dark:prose-invert"
dangerouslySetInnerHTML={{ __html: htmlContent }}
/>
</CardContent>
</Card>
);
}
Primitives required in your
@/components/ui
directory.
| Component | Path |
|---|---|
| card | @/components/ui/card |
Types and interfaces defined in this component.
interface AIMessageMarkdown01Props {
htmlContent?: string; // HTML string content for AI response
} interface AIMessageMarkdown01Props {
htmlContent?: string; // HTML string content for AI response
} Internal functions used to handle component logic.
| Function | Parameters |
|---|---|
| AIMessageMarkdown01() | { htmlContent = ` <h1>Hello from ChatGPT</h1> <p>This is a rich AI response with <strong>bold</strong>, <em>italic</em>, and <code>inline code</code>.</p> <h2>Code Example</h2> <pre><code class="language-ts"> function greet(name: string |
Every JSX/HTML tag used in this component, with usage count and source.
| Tag | Count | Type | Source |
|---|---|---|---|
| <Card> | 1× | | @/components/ui/card |
| <CardContent> | 1× | | @/components/ui/card |
| <a> | 1× | | Native HTML |
| <code> | 2× | | Native HTML |
| <div> | 1× | | Native HTML |
| <em> | 1× | | Native HTML |
| <h1> | 1× | | Native HTML |
| <h2> | 2× | | Native HTML |
| <li> | 3× | | Native HTML |
| <p> | 1× | | Native HTML |
| <pre> | 1× | | Native HTML |
| <strong> | 1× | | Native HTML |
| <table> | 1× | | Native HTML |
| <tbody> | 1× | | Native HTML |
| <td> | 6× | | Native HTML |
| <th> | 2× | | Native HTML |
| <thead> | 1× | | Native HTML |
| <tr> | 4× | | Native HTML |
| <ul> | 1× | | Native HTML |