StealThis .dev

Chat Widget

Floating chat widget with bubble toggle, message thread, typing indicator, emoji picker, and auto-scroll. No dependencies.

Open in Lab
css vanilla-js
Targets: JS HTML

Code

Chat Widget

A floating bottom-right chat widget with an expandable chat window, message bubbles, a typing indicator with dots animation, an emoji picker, auto-scroll, and simulated bot replies.

Features

  • Floating launcher button with unread badge
  • Chat window opens/closes with spring animation
  • Message thread: user vs. bot bubbles with timestamps
  • Typing indicator (three-dot pulse animation) before bot replies
  • Inline emoji picker grid toggled from toolbar
  • Send on Enter (Shift+Enter for new line) or send button
  • Auto-scroll to latest message
  • Welcome message on first open
  • Support agent header with online status dot

How it works

  1. sendMessage() appends user bubble, shows typing indicator after 600 ms, then appends bot reply after 1–2 s
  2. Bot replies cycle through a predefined array of welcome responses
  3. Emoji picker is a <div> grid of Unicode emoji that appends to textarea on click
  4. scrollToBottom() called after every DOM append using scrollTop = scrollHeight