Section
AI Chat Interface — Sharp Glassmorphism
Frosted-glass AI chat surface floating over a living gradient mesh. Translucent layered panels, luminous edges, a cyan glow status dot, a bouncing typing indicator, prompt chips, and a gradient send button create depth and atmosphere.
- Section
- Tailwind
- HTML
- MIT
Preview
Live section
9:41 100%
devsnips.dev/library/tailwind/sections/ai-product/ai-chat-interface/sharp-glassmorphism/ fluid · no fixed width 100%
Install
Add to your project
npx devsnips add Tailwind/Sections/AI-Product/ai-chat-interface/sharp-glassmorphism Tailwind/Sections/AI-Product/ai-chat-interface/sharp-glassmorphism <!--
Snippet Name: AI Chat Interface — Sharp Glassmorphism
Description: Frosted-glass chat panel over a vibrant animated gradient mesh, with a streaming reply, prompt chips, and a glass input bar.
Author: DevSnips Contributors
Usage Example: Drop into a vivid app shell as an AI assistant surface. Prompt chips and input bar are fully wired in preview.html. Requires a colored backdrop behind the panel for the glass to read.
-->
<div class="relative w-full max-w-2xl" data-chat="sg">
<!-- Glass panel -->
<div class="relative overflow-hidden rounded-2xl border border-white/20 bg-white/10 shadow-[0_8px_40px_-12px_rgba(99,102,241,0.45)] backdrop-blur-2xl">
<!-- Top highlight -->
<div class="pointer-events-none absolute inset-x-0 top-0 h-px bg-gradient-to-r from-transparent via-white/50 to-transparent" aria-hidden="true"></div>
<!-- Header -->
<div class="flex items-center justify-between gap-3 border-b border-white/15 px-5 py-4">
<div class="flex items-center gap-3">
<div class="sg-glow flex h-10 w-10 items-center justify-center rounded-xl border border-white/30 bg-white/20 text-white backdrop-blur">
<svg class="h-5 w-5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true">
<path d="M12 3v3M12 18v3M3 12h3M18 12h3M5.6 5.6l2.1 2.1M16.3 16.3l2.1 2.1M5.6 18.4l2.1-2.1M16.3 7.7l2.1-2.1" />
<circle cx="12" cy="12" r="3.2" />
</svg>
</div>
<div class="leading-tight">
<p class="font-sora text-[15px] font-semibold text-white">DevSnips Assistant</p>
<p class="sg-mono mt-1 flex items-center gap-1.5 text-[11px] text-white/70">
<span class="sg-dot"></span> online · glass-v2
</p>
</div>
</div>
<div class="flex items-center gap-1.5">
<button type="button" class="sg-mono hidden rounded-lg border border-white/20 bg-white/5 px-2.5 py-1.5 text-[11px] text-white/80 transition-colors hover:bg-white/15 focus:outline-none focus-visible:ring-2 focus-visible:ring-white/60 sm:block">History</button>
<button type="button" aria-label="New chat" class="flex h-8 w-8 items-center justify-center rounded-lg border border-white/20 bg-white/5 text-white/80 transition-colors hover:bg-white/15 focus:outline-none focus-visible:ring-2 focus-visible:ring-white/60">
<svg class="h-4 w-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M12 5v14M5 12h14" /></svg>
</button>
</div>
</div>
<!-- Messages -->
<div class="chat-scroll max-h-[440px] min-h-[340px] space-y-5 overflow-y-auto px-5 py-6" data-chat-messages>
<!-- User -->
<div class="flex justify-end">
<div class="max-w-[80%] rounded-2xl rounded-br-md border border-white/25 bg-gradient-to-br from-fuchsia-500/40 to-purple-600/40 px-4 py-2.5 backdrop-blur-md">
<p class="sg-mono mb-1 text-[10px] uppercase tracking-wider text-white/60">You</p>
<p class="font-sora text-[14px] font-medium leading-relaxed text-white">How do I animate an accordion with the grid-rows trick?</p>
</div>
</div>
<!-- Assistant -->
<div class="flex justify-start gap-3">
<div class="sg-glow mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-lg border border-white/30 bg-white/20 backdrop-blur">
<svg class="h-3.5 w-3.5 text-white" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><circle cx="12" cy="12" r="3.2" /><path d="M12 3v3M12 18v3M3 12h3M18 12h3" /></svg>
</div>
<div class="max-w-[82%] rounded-2xl rounded-tl-md border border-white/20 bg-white/10 px-4 py-2.5 backdrop-blur-md">
<p class="sg-mono mb-1 text-[10px] uppercase tracking-wider text-white/60">Assistant</p>
<p class="font-sora text-[14px] leading-relaxed text-white/90">
Wrap the panel in <code class="sg-code">grid-rows-[0fr]</code>, animate to <code class="sg-code">grid-rows-[1fr]</code> with <code class="sg-code">transition-[grid-template-rows]</code>, and nest an <code class="sg-code">overflow-hidden</code> wrapper. The row grows from 0 to auto with zero layout cost.
</p>
</div>
</div>
<!-- Typing -->
<div class="flex justify-start gap-3" data-chat-typing>
<div class="sg-glow mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-lg border border-white/30 bg-white/20 backdrop-blur">
<svg class="h-3.5 w-3.5 text-white" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><circle cx="12" cy="12" r="3.2" /><path d="M12 3v3M12 18v3M3 12h3M18 12h3" /></svg>
</div>
<div class="flex items-center gap-1.5 rounded-2xl rounded-tl-md border border-white/20 bg-white/10 px-4 py-3 backdrop-blur-md">
<span class="sg-typing-dot"></span>
<span class="sg-typing-dot" style="animation-delay:.15s"></span>
<span class="sg-typing-dot" style="animation-delay:.3s"></span>
</div>
</div>
</div>
<!-- Prompt suggestions -->
<div class="flex flex-wrap gap-2 border-t border-white/15 px-5 py-3">
<button type="button" class="chat-prompt sg-mono rounded-full border border-white/20 bg-white/10 px-3 py-1.5 text-[11px] text-white/85 backdrop-blur transition-colors hover:bg-white/20 focus:outline-none focus-visible:ring-2 focus-visible:ring-white/60">Explain CSS grid</button>
<button type="button" class="chat-prompt sg-mono rounded-full border border-white/20 bg-white/10 px-3 py-1.5 text-[11px] text-white/85 backdrop-blur transition-colors hover:bg-white/20 focus:outline-none focus-visible:ring-2 focus-visible:ring-white/60">Build a toast</button>
<button type="button" class="chat-prompt sg-mono rounded-full border border-white/20 bg-white/10 px-3 py-1.5 text-[11px] text-white/85 backdrop-blur transition-colors hover:bg-white/20 focus:outline-none focus-visible:ring-2 focus-visible:ring-white/60">Refactor my code</button>
</div>
<!-- Input -->
<form class="flex items-center gap-2 border-t border-white/15 px-5 py-4" data-chat-form>
<div class="relative flex-1">
<input
type="text"
name="prompt"
placeholder="Ask anything…"
aria-label="Message DevSnips Assistant"
class="w-full rounded-xl border border-white/20 bg-white/10 px-4 py-2.5 font-sora text-[14px] text-white placeholder:text-white/40 backdrop-blur focus:border-white/40 focus:outline-none focus-visible:ring-2 focus-visible:ring-white/40"
/>
</div>
<button type="submit" class="sg-glow flex shrink-0 items-center gap-2 rounded-xl border border-white/30 bg-gradient-to-r from-fuchsia-500 to-indigo-500 px-4 py-2.5 font-sora text-[13px] font-semibold text-white transition-opacity hover:opacity-90 focus:outline-none focus-visible:ring-2 focus-visible:ring-white/60">
Send
<svg class="h-3.5 w-3.5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M5 12h14M13 6l6 6-6 6" /></svg>
</button>
</form>
</div>
<style>
[data-chat="sg"] .sg-mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }
[data-chat="sg"] .font-sora { font-family: 'Sora', sans-serif; }
[data-chat="sg"] .sg-code { font-family: 'JetBrains Mono', monospace; font-size: 12px; background: rgba(255,255,255,0.14); padding: 1px 5px; border-radius: 4px; color: #fff; }
[data-chat="sg"] .sg-dot { display: inline-block; height: 6px; width: 6px; border-radius: 9999px; background: #6ee7ff; box-shadow: 0 0 8px #6ee7ff; }
[data-chat="sg"] .sg-typing-dot { height: 7px; width: 7px; border-radius: 9999px; background: rgba(255,255,255,0.7); animation: sg-bounce 1.2s infinite ease-in-out; }
[data-chat="sg"] .sg-glow { box-shadow: 0 0 0 1px rgba(255,255,255,0.08), 0 4px 20px -4px rgba(168,85,247,0.5); }
@keyframes sg-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-5px); opacity: 1; } }
[data-chat="sg"] .chat-scroll::-webkit-scrollbar { width: 6px; }
[data-chat="sg"] .chat-scroll::-webkit-scrollbar-track { background: transparent; }
[data-chat="sg"] .chat-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 9999px; }
[data-chat="sg"] .chat-scroll { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.25) transparent; }
</style>
<script>
(function () {
var root = document.currentScript.closest('[data-chat="sg"]');
if (!root) return;
var form = root.querySelector('[data-chat-form]');
var list = root.querySelector('[data-chat-messages]');
var input = form && form.querySelector('input[name="prompt"]');
var typing = root.querySelector('[data-chat-typing]');
if (!form || !list || !input) return;
function addUser(text) {
if (!text.trim()) return;
var row = document.createElement('div');
row.className = 'flex justify-end';
row.innerHTML = '<div class="max-w-[80%] rounded-2xl rounded-br-md border border-white/25 bg-gradient-to-br from-fuchsia-500/40 to-purple-600/40 px-4 py-2.5 backdrop-blur-md"><p class="sg-mono mb-1 text-[10px] uppercase tracking-wider text-white/60">You</p><p class="font-sora text-[14px] font-medium leading-relaxed text-white"></p></div>';
row.querySelector('p:last-child').textContent = text;
list.appendChild(row);
list.scrollTop = list.scrollHeight;
}
function addBot(text) {
var row = document.createElement('div');
row.className = 'flex justify-start gap-3';
row.innerHTML = '<div class="sg-glow mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-lg border border-white/30 bg-white/20 backdrop-blur"><svg class="h-3.5 w-3.5 text-white" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="3.2" /><path d="M12 3v3M12 18v3M3 12h3M18 12h3" /></svg></div><div class="max-w-[82%] rounded-2xl rounded-tl-md border border-white/20 bg-white/10 px-4 py-2.5 backdrop-blur-md"><p class="sg-mono mb-1 text-[10px] uppercase tracking-wider text-white/60">Assistant</p><p class="font-sora text-[14px] leading-relaxed text-white/90"></p></div>';
row.querySelector('p:last-child').textContent = text;
list.appendChild(row);
list.scrollTop = list.scrollHeight;
}
var responses = [
'Use the grid-rows-[0fr] to [1fr] trick wrapped in overflow-hidden for buttery height animation.',
'Try a single-open mode: close sibling items on open and toggle aria-expanded on the trigger.',
'Reach for focus-visible:ring utilities plus role="region" and aria-labelledby for accessibility.',
'Drop the snippet into a docs layout — each item toggles independently with no extra wiring.'
];
var i = 0;
function reply(text) {
addUser(text);
if (typing) { typing.style.display = 'flex'; list.scrollTop = list.scrollHeight; }
setTimeout(function () {
if (typing) typing.style.display = 'none';
addBot(responses[i % responses.length]); i++;
}, 1100);
}
form.addEventListener('submit', function (e) {
e.preventDefault();
reply(input.value);
input.value = '';
});
root.querySelectorAll('.chat-prompt').forEach(function (chip) {
chip.addEventListener('click', function () { reply(chip.textContent.trim()); });
});
})();
</script>
</div> 168 lines UTF-8 · LF · Spaces: 2
Continue browsing