Prompt with Model Picker
A prompt box with a small menu to choose how the AI should answer: fast, balanced or deep thinking.
One HTML file with the CSS and JavaScript inside. No library needed. MIT license.
How to use it
- Click Copy the code, or download the file.
- Paste the CSS into your stylesheet, the HTML where you want the component, and the script before the closing body tag.
- Change
--accentat 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>
<!--
Prompt with Model Picker: 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>Prompt with Model Picker | Free AI UI Component</title>
<meta name="description" content="A prompt box with a small menu to choose how the AI should answer: fast, balanced or deep thinking.">
<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 ---- */
.pb{width:min(100%,680px);background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow);padding:10px 10px 10px 14px;transition:border-color .15s}
.pb:focus-within{border-color:var(--accent)}
.pb textarea{width:100%;border:0;outline:0;resize:none;background:none;min-height:24px;max-height:200px;line-height:1.5;padding:6px 0;color:var(--ink)}
.pb textarea::placeholder{color:var(--muted)}
.row{display:flex;align-items:center;gap:8px;min-width:0}
.row>span{min-width:0}
.sp{flex:1}
.ib{width:36px;height:36px;display:grid;place-items:center;border-radius:10px;border:0;background:none;color:var(--muted);cursor:pointer}
.ib:hover{background:var(--surface-2);color:var(--ink)}
.send{width:36px;height:36px;display:grid;place-items:center;border-radius:10px;border:0;background:var(--accent);color:var(--accent-ink);cursor:pointer;transition:opacity .15s,transform .1s}
.send:disabled{opacity:.35;cursor:not-allowed}
.send:not(:disabled):active{transform:scale(.94)}
.log{width:min(100%,680px);margin-bottom:12px;display:flex;flex-direction:column;gap:8px}
.msg{align-self:flex-end;max-width:85%;background:var(--accent-soft);color:var(--ink);padding:9px 13px;border-radius:14px 14px 4px 14px;white-space:pre-wrap;word-wrap:break-word;animation:pop .2s ease}
@keyframes pop{from{opacity:0;transform:translateY(6px)}}
.wrap{width:min(100%,680px);display:flex;flex-direction:column;align-items:stretch}
.pick{position:relative}
.pbtn{display:flex;align-items:center;gap:6px;border:1px solid var(--line);background:var(--surface-2);color:var(--ink);border-radius:999px;padding:5px 10px 5px 12px;font-size:13px;font-weight:600;cursor:pointer}
.pbtn:hover{border-color:var(--accent)}
.plist{position:absolute;left:0;bottom:calc(100% + 8px);width:260px;background:var(--surface);border:1px solid var(--line);border-radius:12px;box-shadow:var(--shadow);padding:6px;list-style:none;margin:0;z-index:2}
.plist[hidden]{display:none}
.plist li{display:grid;grid-template-columns:1fr auto;gap:2px 10px;padding:9px 10px;border-radius:8px;cursor:pointer}
.plist li:hover,.plist li:focus{background:var(--surface-2);outline:0}
.plist li b{color:var(--ink);font-size:14px}.plist li span{grid-column:1;color:var(--muted);font-size:12.5px}
.plist li i{grid-row:1/3;grid-column:2;align-self:center;color:var(--accent);visibility:hidden}
.plist li[aria-selected=true] i{visibility:visible}
</style>
</head>
<body>
<div class="wrap">
<form class="pb" id="f">
<label class="sr" for="q">Message</label>
<textarea id="q" rows="1" placeholder="Ask anything"></textarea>
<div class="row">
<div class="pick">
<button class="pbtn" id="pb" type="button" aria-haspopup="listbox" aria-expanded="false"><span id="cur">Balanced</span><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></button>
<ul class="plist" id="pl" role="listbox" aria-label="Answer mode" hidden>
<li role="option" tabindex="-1" data-v="Fast" aria-selected="false"><b>Fast</b><span>Quick answers for simple questions</span><i><svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 12l5 5L20 6"/></svg></i></li>
<li role="option" tabindex="-1" data-v="Balanced" aria-selected="true"><b>Balanced</b><span>Good for most everyday tasks</span><i><svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 12l5 5L20 6"/></svg></i></li>
<li role="option" tabindex="-1" data-v="Deep thinking" aria-selected="false"><b>Deep thinking</b><span>Slower, better for hard problems</span><i><svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 12l5 5L20 6"/></svg></i></li>
</ul>
</div>
<span class="sp"></span><button class="send" id="s" type="submit" aria-label="Send message" disabled><svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 19V5M5 12l7-7 7 7"/></svg></button>
</div>
</form>
</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;})();
function grow(t){t.style.height='auto';t.style.height=Math.min(t.scrollHeight,200)+'px'}
function post(log,text){var m=document.createElement('div');m.className='msg';m.textContent=text;log.appendChild(m);}
var pb=document.getElementById('pb'),pl=document.getElementById('pl'),cur=document.getElementById('cur'),q=document.getElementById('q'),s=document.getElementById('s'),items=[].slice.call(pl.querySelectorAll('li'));
function open(v){pl.hidden=!v;pb.setAttribute('aria-expanded',v);if(v){var a=pl.querySelector('[aria-selected=true]')||items[0];a.focus();}}
function choose(li){items.forEach(function(x){x.setAttribute('aria-selected',x===li);});cur.textContent=li.dataset.v;open(false);pb.focus();}
pb.addEventListener('click',function(){open(pl.hidden);});
items.forEach(function(li,i){li.addEventListener('click',function(){choose(li);});
li.addEventListener('keydown',function(e){if(e.key==='ArrowDown'){e.preventDefault();items[(i+1)%items.length].focus();}
if(e.key==='ArrowUp'){e.preventDefault();items[(i-1+items.length)%items.length].focus();}
if(e.key==='Enter'||e.key===' '){e.preventDefault();choose(li);}if(e.key==='Escape'){open(false);pb.focus();}});});
document.addEventListener('click',function(e){if(!e.target.closest('.pick'))open(false);});
q.addEventListener('input',function(){grow(q);s.disabled=!q.value.trim();});
document.getElementById('f').addEventListener('submit',function(e){e.preventDefault();q.value='';grow(q);s.disabled=true;});
</script>
</body>
</html>
More prompt input components
Basic Prompt Box
A clean prompt box. Enter sends, Shift and Enter adds a new line, and the send button stays off until there is text.
Auto-Growing Prompt
A prompt that grows as people type, stops at a set height and then scrolls. Shows a live character count.
Prompt with File Attachments
Attach files with a button or by dragging them onto the box. Each file shows as a chip with its size and a remove button.
Prompt with Voice Input
A microphone button that turns speech into text when the browser supports it, with a pulsing record state and a timer.
Prompt with Slash Commands
Type a slash to open a command menu. Use the arrow keys to move, Enter to pick, and Escape to close.
Prompt Suggestions
Starter ideas shown as buttons above an empty prompt. Clicking one fills the box so people can edit it before sending.