100 Free AI UI Components

Sidebar with Pinned Chats and Folders

A chat sidebar with a pinned section and folders you can open and close, like projects. It remembers which folders are open.

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>
<!--
  Sidebar with Pinned Chats and Folders: 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>Sidebar with Pinned Chats and Folders | Free AI UI Component</title>
<meta name="description" content="A chat sidebar with a pinned section and folders you can open and close, like projects. It remembers which folders are open.">
<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 ---- */
.side{width:min(100%,300px);background:var(--surface-2);border:1px solid var(--line);border-radius:var(--radius);padding:10px;max-height:calc(100vh - 48px);overflow-y:auto}
h2{font-size:11.5px;color:var(--muted);text-transform:uppercase;letter-spacing:.05em;margin:8px 8px 6px;display:flex;align-items:center;gap:6px}
ul{list-style:none;margin:0;padding:0}
a.c{display:block;padding:7px 10px;border-radius:8px;color:var(--text);text-decoration:none;font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
a.c:hover{background:var(--surface)}a.c[aria-current=page]{background:var(--surface);color:var(--ink);font-weight:600}
.fold{width:100%;display:flex;align-items:center;gap:8px;border:0;background:none;padding:8px 10px;border-radius:8px;color:var(--ink);font-size:14px;font-weight:600;cursor:pointer;text-align:left}
.fold:hover{background:var(--surface)}
.fold .n{margin-left:auto;font-size:12px;color:var(--muted);font-weight:500}
.fold .ch{transition:transform .15s;color:var(--muted);display:grid}.fold[aria-expanded=false] .ch{transform:rotate(-90deg)}
.fold+ul{padding-left:22px}
.pinned a.c{display:flex;gap:8px;align-items:center}.pinned svg{color:var(--accent);flex:none}
</style>
</head>
<body>
<nav class="side" aria-label="Chats" id="side">
  <h2><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 17v5M9 3h6l-1 6 4 4H6l4-4z"/></svg>Pinned</h2><ul class="pinned" id="pinned"></ul>
  <h2>Folders</h2><ul id="folders"></ul>
</nav>
<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 PINNED=['Company handbook questions','Quarterly report draft'];
var FOLDERS=[['Website redesign',['Homepage copy','Color ideas','Launch checklist']],['Spanish practice',['Ordering food','Past tense drills']],['Home',['Kitchen renovation budget','Garden plan for spring','Moving checklist']]];
var PIN='<svg viewBox=\"0 0 24 24\" width=\"14\" height=\"14\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"M12 17v5M9 3h6l-1 6 4 4H6l4-4z\"/></svg>',FOLD='<svg viewBox=\"0 0 24 24\" width=\"16\" height=\"16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"M3 6h7l2 2h9v11H3z\"/></svg>',CH='<svg viewBox=\"0 0 24 24\" width=\"14\" height=\"14\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"M6 9l6 6 6-6\"/></svg>';
var openState={0:true};  // Replace with saved state from your app, for example localStorage.
function link(t){var a=document.createElement('a');a.className='c';a.href='#';a.textContent=t;a.addEventListener('click',function(e){e.preventDefault();document.querySelectorAll('a.c').forEach(function(x){x.removeAttribute('aria-current');});a.setAttribute('aria-current','page');});return a;}
PINNED.forEach(function(t){var li=document.createElement('li'),a=link(t);a.insertAdjacentHTML('afterbegin',PIN);li.appendChild(a);document.getElementById('pinned').appendChild(li);});
FOLDERS.forEach(function(f,i){var li=document.createElement('li'),b=document.createElement('button'),ul=document.createElement('ul');b.type='button';b.className='fold';ul.id='fo'+i;
  b.innerHTML='<span class="ch">'+CH+'</span>'+FOLD+'<span></span><span class="n">'+f[1].length+'</span>';b.children[2].textContent=f[0];b.setAttribute('aria-controls',ul.id);
  f[1].forEach(function(t){var l=document.createElement('li');l.appendChild(link(t));ul.appendChild(l);});
  function set(v){b.setAttribute('aria-expanded',v);ul.hidden=!v;openState[i]=v;}
  b.addEventListener('click',function(){set(ul.hidden);});set(!!openState[i]);li.appendChild(b);li.appendChild(ul);document.getElementById('folders').appendChild(li);});
document.querySelector('#fo0 a.c').setAttribute('aria-current','page');
</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.