100 Free AI UI Components

Share Conversation Dialog

Share a chat with a link. Choose who can see it, whether to show your name, then copy the link with one click.

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>
<!--
  Share Conversation Dialog: 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>Share Conversation Dialog | Free AI UI Component</title>
<meta name="description" content="Share a chat with a link. Choose who can see it, whether to show your name, then copy the link with one click.">
<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 ---- */
.btn{display:inline-flex;align-items:center;gap:8px;border:1px solid var(--line);background:var(--surface);color:var(--ink);border-radius:10px;padding:9px 16px;font-size:14px;font-weight:600;cursor:pointer}
.btn:hover{border-color:var(--accent)}.btn.pri{background:var(--accent);border-color:var(--accent);color:var(--accent-ink)}
dialog{border:0;border-radius:18px;padding:0;width:min(92vw,460px);background:var(--surface);color:var(--text);box-shadow:0 30px 80px -20px rgba(0,0,0,.5)}
dialog::backdrop{background:rgba(10,10,20,.45)}
.dg{padding:20px 22px}.dg h2{margin:0 0 4px;font-size:18px;color:var(--ink)}.dg>p{margin:0 0 16px;color:var(--muted);font-size:14px}
.opt{display:flex;flex-direction:column;gap:8px;margin-bottom:14px;border:0;padding:0}
.opt label{display:flex;gap:10px;align-items:flex-start;border:1.5px solid var(--line);border-radius:12px;padding:10px 12px;cursor:pointer}
.opt label:has(input:checked){border-color:var(--accent);background:var(--accent-soft)}
.opt input{accent-color:var(--accent);margin-top:3px}
.opt b{display:block;color:var(--ink);font-size:14px}.opt small{color:var(--muted);font-size:12.5px}
.chk{display:flex;gap:8px;align-items:center;font-size:14px;margin-bottom:14px;color:var(--ink)}.chk input{accent-color:var(--accent);width:16px;height:16px}
.link{display:flex;gap:8px;align-items:center;border:1px solid var(--line);border-radius:12px;padding:6px 6px 6px 12px;background:var(--surface-2)}
.link input{flex:1;border:0;outline:0;background:none;color:var(--text);font:13px var(--mono);min-width:0}
.link.off{opacity:.5}
.x{position:absolute;top:12px;right:12px;width:32px;height:32px;border:0;background:none;color:var(--muted);border-radius:8px;cursor:pointer;display:grid;place-items:center}
.x:hover{background:var(--surface-2);color:var(--ink)}
</style>
</head>
<body>
<button class="btn" id="open" type="button" aria-haspopup="dialog"><svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M10 14a5 5 0 007 0l3-3a5 5 0 00-7-7l-1 1M14 10a5 5 0 00-7 0l-3 3a5 5 0 007 7l1-1"/></svg>Share chat</button>
<dialog id="dlg" aria-labelledby="dh"><div class="dg" style="position:relative">
  <button class="x" id="x" type="button" aria-label="Close"><svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" aria-hidden="true"><path d="M6 6l12 12M18 6L6 18"/></svg></button>
  <h2 id="dh">Share this chat</h2><p>People with the link can read the chat. New messages you send later are not shared.</p>
  <fieldset class="opt"><legend class="sr">Who can see it</legend>
    <label><input type="radio" name="v" value="private" checked><span><b>Only me</b><small>The link will not work for anyone else.</small></span></label>
    <label><input type="radio" name="v" value="link"><span><b>Anyone with the link</b><small>They do not need an account.</small></span></label></fieldset>
  <label class="chk"><input type="checkbox" id="nm"> Show my name on the shared page</label>
  <div class="link off" id="lk"><label class="sr" for="url">Share link</label><input id="url" readonly value="https://example.com/share/party-planning-7f3k"><button class="btn pri" type="button" id="cp" disabled>Copy link</button></div>
</div></dialog>
<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 dlg=document.getElementById('dlg'),lk=document.getElementById('lk'),cp=document.getElementById('cp'),url=document.getElementById('url');
function update(){var pub=document.querySelector('input[name=v]:checked').value==='link';lk.classList.toggle('off',!pub);cp.disabled=!pub;}
document.querySelectorAll('input[name=v]').forEach(function(r){r.addEventListener('change',update);});
document.getElementById('open').addEventListener('click',function(){dlg.showModal();});
document.getElementById('x').addEventListener('click',function(){dlg.close();});
dlg.addEventListener('click',function(e){if(e.target===dlg)dlg.close();});
dlg.addEventListener('close',function(){document.getElementById('open').focus();});
cp.addEventListener('click',function(){url.select();var done=function(){cp.textContent='Copied';setTimeout(function(){cp.textContent='Copy link';},1500);};
  if(navigator.clipboard&&window.isSecureContext)navigator.clipboard.writeText(url.value).then(done,function(){document.execCommand('copy');done();});else{document.execCommand('copy');done();}});
update();
</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.