100 Free AI UI Components

Conversation Search

Search through past chats as you type. Matching words are highlighted, and a friendly message appears when nothing is found.

One HTML file with the CSS and JavaScript inside. No library needed. MIT license.

Live preview

How to use it

  1. Click Copy the code, or download the file.
  2. Paste the CSS into your stylesheet, the HTML where you want the component, and the script before the closing body tag.
  3. Change --accent at the top of the CSS to your brand color, then connect the events to your AI service.

What you get

  • Works in light and dark mode automatically
  • Keyboard friendly, with labels for screen readers
  • Fits phones, tablets and desktops
  • Respects the reduced motion setting
  • No framework, so it works with any stack

The code

<!DOCTYPE html>
<!--
  Conversation Search: a free AI UI component
  From 100 Free AI UI Components by MM Rahman Bappi, MIT license
  https://mmrahmanbappi.github.io/100-free-ai-ui-components/

  How to use: copy the CSS, HTML and JavaScript below into your page.
  Colors are CSS variables at the top. Change --accent to match your brand.
  Light and dark themes follow the visitor's system setting, or set
  data-theme="dark" or data-theme="light" on the html element.
-->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Conversation Search | Free AI UI Component</title>
<meta name="description" content="Search through past chats as you type. Matching words are highlighted, and a friendly message appears when nothing is found.">
<meta name="robots" content="noindex, follow">
<style>
:root{
  --accent:#5b5bd6; --accent-ink:#fff; --accent-soft:#ececfc;
  --bg:#f7f7f8; --surface:#fff; --surface-2:#f1f1f4; --ink:#17171c; --text:#3a3a44; --muted:#6c6c78;
  --line:#e3e3e8; --good:#15803d; --warn:#b45309; --bad:#c62828;
  --radius:14px; --shadow:0 1px 2px rgba(20,20,30,.06),0 8px 24px -12px rgba(20,20,30,.18);
  --font:system-ui,-apple-system,"Segoe UI",Roboto,Ubuntu,sans-serif; --mono:ui-monospace,"Cascadia Code",Menlo,Consolas,monospace;
}
@media (prefers-color-scheme:dark){:root:not([data-theme=light]){
  --accent:#8b8bff; --accent-ink:#0f0f16; --accent-soft:#25254a;
  --bg:#0f0f13; --surface:#18181f; --surface-2:#212129; --ink:#f3f3f6; --text:#d4d4dc; --muted:#9a9aa8;
  --line:#2c2c36; --good:#4ade80; --warn:#fbbf24; --bad:#f87171; --shadow:0 1px 2px rgba(0,0,0,.4),0 10px 30px -12px rgba(0,0,0,.6);
}}
:root[data-theme=dark]{
  --accent:#8b8bff; --accent-ink:#0f0f16; --accent-soft:#25254a;
  --bg:#0f0f13; --surface:#18181f; --surface-2:#212129; --ink:#f3f3f6; --text:#d4d4dc; --muted:#9a9aa8;
  --line:#2c2c36; --good:#4ade80; --warn:#fbbf24; --bad:#f87171; --shadow:0 1px 2px rgba(0,0,0,.4),0 10px 30px -12px rgba(0,0,0,.6);
}
*{box-sizing:border-box}
html,body{margin:0}
body{min-height:100vh;display:grid;grid-template-columns:minmax(0,1fr);place-items:center;padding:24px;background:var(--bg);color:var(--text);font:15px/1.5 var(--font);-webkit-font-smoothing:antialiased}
button,input,textarea,select{font:inherit;color:inherit}
:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
[hidden]{display:none!important}
.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition:none!important}}
/* ---- component ---- */
.wrap{width:min(100%,560px);background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow);overflow:hidden}
.sb{display:flex;align-items:center;gap:10px;padding:12px 16px;border-bottom:1px solid var(--line);color:var(--muted)}
.sb input{flex:1;border:0;outline:0;background:none;color:var(--ink);font-size:15px;min-width:0}
.sb kbd{font:11.5px var(--mono);border:1px solid var(--line);border-radius:5px;padding:1px 6px;color:var(--muted)}
ul{list-style:none;margin:0;padding:6px;max-height:340px;overflow-y:auto}
li a{display:block;padding:10px 12px;border-radius:10px;text-decoration:none;color:inherit}
li a:hover,li a:focus{background:var(--surface-2);outline:0}
li b{display:block;color:var(--ink);font-size:14px}li span{display:block;color:var(--muted);font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
li small{color:var(--muted);font-size:12px}
mark{background:color-mix(in srgb,var(--accent) 25%,transparent);color:inherit;border-radius:3px;padding:0 1px}
.empty{padding:28px 16px;text-align:center;color:var(--muted);font-size:14px}
.count{padding:8px 16px;font-size:12px;color:var(--muted);border-top:1px solid var(--line)}
</style>
</head>
<body>
<div class="wrap" role="search">
  <div class="sb"><svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="M20 20l-4-4"/></svg><label class="sr" for="q">Search chats</label><input id="q" type="search" placeholder="Search your chats" autocomplete="off"><kbd>Esc</kbd></div>
  <ul id="res"></ul>
  <div class="count" id="cnt" role="status" aria-live="polite"></div>
</div>
<script>
// Demo helper: add ?theme=dark or ?theme=light to the address to preview a theme.
(function(){var t=new URLSearchParams(location.search).get('theme');if(t)document.documentElement.dataset.theme=t;})();
var CHATS=[['Trip to Lisbon','Day 2: visit the tram 28 route and the castle before lunch.','Mon'],['Email to my landlord','Write a polite email about the broken heater in the kitchen.','Mon'],
['Explain compound interest','Interest on your interest makes savings grow faster over time.','Sun'],['Fix my CSS grid','Use minmax(0, 1fr) so long words do not break the layout.','Sat'],
['Birthday gift ideas','A cooking class, a plant, or a photo book from your trip.','Sep 12'],['Weekly meal plan','Monday: lentil soup. Tuesday: tacos. Wednesday: pasta with greens.','Sep 10'],['Resume feedback','Move your strongest project to the top and cut the summary to two lines.','Sep 8']];
var q=document.getElementById('q'),res=document.getElementById('res'),cnt=document.getElementById('cnt');
function esc(s){return s.replace(/[&<>"]/g,function(c){return {'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;'}[c];});}
function hl(text,t){var e=esc(text);if(!t)return e;var re=new RegExp('('+t.replace(/[.*+?^${}()|[\]\\]/g,'\\$&')+')','ig');return e.replace(re,'<mark>$1</mark>');}
function render(){var t=q.value.trim(),list=CHATS.filter(function(c){return !t||(c[0]+' '+c[1]).toLowerCase().indexOf(t.toLowerCase())>-1;});
  res.innerHTML=list.length?'':'<li class="empty">No chats match "'+esc(t)+'". Try a different word.</li>';
  list.forEach(function(c){var li=document.createElement('li');li.innerHTML='<a href="#"><b>'+hl(c[0],t)+'</b><span>'+hl(c[1],t)+'</span><small>'+c[2]+'</small></a>';res.appendChild(li);});
  cnt.textContent=t?list.length+(list.length===1?' chat found':' chats found'):CHATS.length+' chats';}
q.addEventListener('input',render);q.addEventListener('keydown',function(e){if(e.key==='Escape'){q.value='';render();}});render();
</script>
</body>
</html>

More chat layouts components

  • Full Chat Window

    A complete chat screen with a header, scrolling messages and a prompt box at the bottom. Replies stream in, and the view follows along.

  • Chat Sidebar

    A sidebar with past chats grouped by date, a New chat button and the current chat highlighted. On phones it slides in from a menu button.

  • Empty Chat Welcome Screen

    The first screen of a new chat: a greeting, example prompts, what the assistant can do and its limits, with the prompt box ready below.

  • Floating Chat Widget

    A round chat button in the corner that opens a small chat panel, with an unread badge. Escape or the close button hides it again.

  • Split View: Chat and Document

    Chat on one side and a live document on the other, the layout used by AI writing tools. On phones it switches to two tabs.

  • Mobile Chat Screen

    A phone-sized chat with a back button, assistant name and status, messages, and a prompt bar with an attach button, sized for thumbs.