A modern, responsive AI chat interface component built with Next.js, TypeScript, Tailwind CSS, and shadcn/ui.
- π¨ Modern UI Design - Clean, professional interface with gradient backgrounds and smooth animations
- π± Fully Responsive - Works perfectly on desktop, tablet, and mobile devices
- β¨οΈ Keyboard Shortcuts - Press Enter to send messages, Shift+Enter for new lines
- π― Interactive Prompts - Quick-start buttons for common AI tasks
- π¬ Real-time Chat - Smooth message flow with typing indicators
- π Theme Support - Built-in dark/light mode compatibility
- βΏ Accessible - WCAG compliant with proper focus management
- π Performance Optimized - Fast loading and smooth interactions
- Framework: Next.js 14 with App Router
- Language: TypeScript
- Styling: Tailwind CSS
- UI Components: shadcn/ui
- Icons: Lucide React
- Package Manager: pnpm
-
Clone the repository
git clone <repository-url> cd ai-assistant-card
-
Install dependencies
pnpm install
-
Run the development server
pnpm run dev
-
Open your browser Navigate to http://localhost:3000
import { Component as AIAssistantCard } from "@/components/ui/ai-assistant-card";
export default function ChatPage() {
return (
<div className="min-h-screen flex items-center justify-center p-4">
<AIAssistantCard />
</div>
);
}- Click on any badge to auto-fill the input with suggested prompts
- Categories: Image Creation, Data Analysis, Planning, Text Summarization, Writing, and More
- Type your message and press Enter to send
- Messages appear in a chat-like interface
- AI responses are simulated with "I am AI" for demo purposes
- Choose from different AI models (GPT-4, GPT-3.5, etc.)
- Located above the input field for easy access
- Adapts to different screen sizes
- Mobile-optimized touch interactions
- Scalable text and spacing
The component uses Tailwind CSS classes and can be customized by modifying:
// Main card styling
<Card className="flex h-full min-h-[600px] sm:min-h-[700px] lg:min-h-[800px] w-full max-w-[320px] sm:max-w-[400px] lg:max-w-[480px] flex-col gap-4 sm:gap-6 p-4 sm:p-6 shadow-lg border-0 bg-gradient-to-br from-background to-muted/20">
// Message bubbles
<div className="bg-gradient-to-br from-primary to-primary/90 text-primary-foreground">
// Input field
<Textarea className="bg-muted/30 hover:bg-muted/40 focus:bg-muted/50 ... border-2 border-border/40 hover:border-border/70 focus:border-primary/70">Modify the badge colors by updating the className:
// Blue badge
className="... border-blue-200/50 bg-blue-50/50 hover:bg-blue-100/50 text-blue-700"
// Orange badge
className="... border-orange-200/50 bg-orange-50/50 hover:bg-orange-100/50 text-orange-700"Replace the fake API call with your actual endpoint:
const sendMessage = async () => {
// Replace this with your API call
const response = await fetch('/api/chat', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ message: inputValue, model: selectedModel })
});
const data = await response.json();
// Handle response...
};src/
βββ app/
β βββ globals.css # Global styles with Tailwind
β βββ layout.tsx # Root layout
β βββ page.tsx # Demo page
βββ components/ui/ # shadcn/ui components
β βββ ai-assistant-card.tsx # Main AI chat component
β βββ badge.tsx
β βββ button.tsx
β βββ card.tsx
β βββ select.tsx
β βββ textarea.tsx
βββ lib/
βββ utils.ts # Utility functions
# Development
pnpm run dev # Start development server
pnpm run build # Build for production
pnpm run start # Start production server
pnpm run lint # Run ESLintThe main component accepts the following customization options:
interface AIAssistantCardProps {
// Add custom props here as needed
className?: string;
onMessageSend?: (message: string) => void;
onModelChange?: (model: string) => void;
}- Mobile-first approach
- Breakpoints:
sm:(640px+),lg:(1024px+) - Adaptive text sizes and spacing
- Proper ARIA labels
- Keyboard navigation support
- Focus management
- Screen reader friendly
- Optimized re-renders with React hooks
- Smooth animations with CSS transitions
- Lazy loading where applicable
- Intuitive interface design
- Clear visual feedback
- Smooth interactions
- Loading states
-
Build Errors
# Clear cache and reinstall rm -rf node_modules .next pnpm install pnpm run build -
Styling Issues
- Ensure Tailwind CSS is properly configured
- Check that all shadcn/ui components are installed
-
TypeScript Errors
- Verify all dependencies are installed
- Check tsconfig.json configuration
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- shadcn/ui for the beautiful UI components
- Tailwind CSS for the utility-first CSS framework
- Lucide for the icon set
- Next.js for the React framework
Made with β€οΈ by [KJAIML]