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.

Live Preview — ai-message-markdown-01

Hello from ChatGPT

This is a rich AI response with bold, italic, and inline code.

Code Example


function greet(name: string) {
  return `Hello, ${name}!`;
}
console.log(greet("World"));
    

Features

  • Lists support
  • Tables support
  • Links: ShadCN UI
Feature Supported
Code blocks
Tables
Lists

Installation

Shadcn UI Setup

Add the necessary Shadcn UI primitives.

npm
npx shadcn-ui@latest add card

Source Code

ai-message-markdown-01.tsx
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>
    );
}

Shadcn Components

Primitives required in your @/components/ui directory.

Component Path
card @/components/ui/card

Type Reference

Types and interfaces defined in this component.

AIMessageMarkdown01Props
interface AIMessageMarkdown01Props {
    htmlContent?: string; // HTML string content for AI response
}

Functional Logic

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

JSX Tags Usage

Every JSX/HTML tag used in this component, with usage count and source.

Tag Count Type Source
<Card> Library @/components/ui/card
<CardContent> Library @/components/ui/card
<a> Native Native HTML
<code> Native Native HTML
<div> Native Native HTML
<em> Native Native HTML
<h1> Native Native HTML
<h2> Native Native HTML
<li> Native Native HTML
<p> Native Native HTML
<pre> Native Native HTML
<strong> Native Native HTML
<table> Native Native HTML
<tbody> Native Native HTML
<td> Native Native HTML
<th> Native Native HTML
<thead> Native Native HTML
<tr> Native Native HTML
<ul> Native Native HTML

Related Components

  • AI Chat Bubble — A conversational chat bubble component with typing indicator, avatar support, and message timestamps for AI chat interfaces.
  • AI Chat Input Bar — A modern chat input bar with send button, attachment support, and auto-resize textarea for AI conversation interfaces.
  • AI Chat Window — A full-featured AI chat window with message history, streaming response animation, and conversation management.
  • AI Streaming Text — A typewriter-style streaming text component that simulates token-by-token AI response generation with cursor animation.
  • AI Chat Sidebar — A conversation history sidebar listing previous AI chat sessions with search, date grouping, and active state indicators.
  • AI Model Selector — A dropdown model selector for choosing between AI models (GPT-4, Claude, Gemini) with model info badges and capability indicators.