Documentation

AI Response

Plain text display for AI responses with markdown rendering, syntax highlighting, streaming cursor, and action buttons. No card or wrapper styling - just the text content.

Installation

1import { AiResponseComponent } from '@angular-ai-kit/core';

Live Demo

Welcome to Angular AI Kit

This is a comprehensive demonstration of all markdown features supported by the AI Response component.

Text Formatting

You can use bold text, italic text, and strikethrough. You can also combine them: bold and italic, or bold strikethrough.

Lists

Unordered Lists

  • First item
  • Second item
    • Nested item 2.1
    • Nested item 2.2
      • Deeply nested item
  • Third item

Ordered Lists

  1. First step
  2. Second step
    1. Sub-step 2.1
    2. Sub-step 2.2
  3. Third step

Task Lists

  • Completed task
  • Another completed task
  • Pending task
  • Future task

Code Examples

TypeScript

typescript
interface ChatMessage {
  id: string;
  role: 'user' | 'assistant' | 'system';
  content: string;
  timestamp: Date;
}

function formatMessage(message: ChatMessage): string {
  const { role, content, timestamp } = message;
  return `[${timestamp.toISOString()}] ${role}: ${content}`;
}

const message: ChatMessage = {
  id: crypto.randomUUID(),
  role: 'assistant',
  content: 'Hello, how can I help you today?',
  timestamp: new Date()
};

console.log(formatMessage(message));

Python

python
from dataclasses import dataclass
from datetime import datetime
from typing import Literal

@dataclass
class ChatMessage:
    id: str
    role: Literal['user', 'assistant', 'system']
    content: str
    timestamp: datetime

def format_message(message: ChatMessage) -> str:
    return f"[{message.timestamp.isoformat()}] {message.role}: {message.content}"

# Example usage
message = ChatMessage(
    id="123",
    role="assistant",
    content="Hello! How can I assist you?",
    timestamp=datetime.now()
)
print(format_message(message))

JSON Configuration

json
{
  "name": "angular-ai-kit",
  "version": "1.0.0",
  "features": {
    "markdown": true,
    "streaming": true,
    "codeHighlighting": true
  },
  "themes": ["light", "dark"]
}

CSS Styling

css
.ai-response {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1rem;
}

.ai-response:hover {
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

Bash Commands

bash
# Install dependencies
npm install @angular-ai-kit/core

# Generate a new component
npx nx generate @angular-ai-kit/core:component my-chat

# Run the development server
npm run dev

Inline code is also supported: const greeting = "Hello, World!";

Blockquotes

This is a simple blockquote. It's great for highlighting important information.

Note: You can use formatting inside blockquotes too.

Even multiple paragraphs work!

And nested blockquotes as well.

Tables

Feature Status Notes
Markdown Rendering Full GFM support
Code Highlighting Multiple languages
Streaming Text Character-by-character
Dark Mode CSS variables
Copy to Clipboard Per code block

Links

Horizontal Rules

Content above the rule.


Content below the rule.

Mathematical Expressions

While LaTeX isn't natively supported, you can write equations inline: E = mc² or a² + b² = c².

Summary

This component supports:

  1. Rich text formatting - Bold, italic, strikethrough
  2. Structured content - Lists, tables, blockquotes
  3. Code presentation - Syntax highlighting for 20+ languages
  4. Interactive features - Copy buttons, action buttons
  5. Accessibility - Full ARIA support, keyboard navigation

Configuration

Show Actions
Show Cursor

API Reference

Inputs

Prop Type Default Description
content string required Markdown content to display
isStreaming boolean false Whether content is currently streaming
showActions boolean true Show action buttons (copy, regenerate, thumbs)
showCursor boolean true Show blinking cursor during streaming
showCopy boolean true Show copy button
showRegenerate boolean true Show regenerate button
showFeedback boolean true Show feedback buttons (thumbs up/down)
actionsAlwaysVisible boolean false Always show actions (vs hover)
showAvatar boolean true Show AI avatar
customClasses string '' Additional CSS classes

Outputs

Prop Type Description
copy string Emits full content when copy is clicked
codeBlockCopy string Emits code content when a code block is copied
regenerate void Emits when regenerate button is clicked
thumbsUp void Emits when thumbs up is clicked
thumbsDown void Emits when thumbs down is clicked

Usage Example

1<ai-response2  [content]="response"3  [isStreaming]="isLoading"4  [showActions]="true"5  (copy)="handleCopy($event)"6  (regenerate)="handleRegenerate()"7  (thumbsUp)="handleThumbsUp()"8  (thumbsDown)="handleThumbsDown()"9/>

Accessibility

  • Uses semantic HTML for content structure
  • Code blocks have accessible copy buttons
  • Action buttons have aria-labels
  • Supports keyboard navigation
  • Respects prefers-reduced-motion for animations