Model Picker with Descriptions
A dropdown for choosing an AI model where each option explains speed, depth and cost, with full keyboard support.
AI prompt
Clean UI mockup of an open model picker dropdown under a button labelled Balanced with a small chevron, a list of three options Fast, Balanced with a check mark and highlighted background, and Deep, each with a one-line description and two small meters labelled Speed and Depth drawn as dots, light theme, rounded menu with thin border and soft shadow, flat modern style. Negative: heavy shadows, clutter, text errors, device frames. Reduced motion: static design.About this pattern
Definition
People pick a model by what it is good for, not by name. A picker that shows a one-line description and simple speed and depth meters lets them choose without reading documentation. It is a listbox opened from a button, with arrow keys, Enter to pick and Escape to close.
Purpose & UX principles
- Use a button with aria-haspopup=listbox and aria-expanded; the options are role=option inside a role=listbox.
- Show name, one short sentence and small meters for speed and depth.
- Mark the current choice with a check and aria-selected.
- Close on Escape and outside click and return focus to the button.
Interaction states
- Open the picker with click, Enter, Space or Arrow Down.
Motion specification
- The menu fades in over 120ms.
- Reduced motion: no fade.
Responsive behaviour
- Do not rely on colour alone for the meters; add text such as Fast.
- Remember the choice so it persists across sessions.
Code
<div class="bx"><div class="wr"><button class="tg" id="tg" type="button" aria-haspopup="listbox" aria-expanded="false" aria-controls="lb"><span id="cur">Balanced</span><i>▾</i></button><ul class="lb" id="lb" role="listbox" aria-label="Model" tabindex="-1" hidden></ul></div><p class="out" id="out" role="status"></p></div>:root{--bg:#F1F1EF;--surface:#fff;--surface-2:#F7F7F5;--line:#E0E0DC;--text:#171717;--muted:#6f6f6f;--accent:#171717;--accent-ink:#fff;--danger:#d92d20}
*{box-sizing:border-box;margin:0}
button{font:inherit;color:inherit;background:none;border:0;padding:0;cursor:pointer}a{color:inherit;text-decoration:none}ul,ol,p,h4{margin:0;padding:0}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
.pre{display:flex;gap:5px;flex-wrap:wrap}.pre button{height:28px;padding:0 11px;border-radius:99px;border:1px solid var(--line);background:var(--surface);font-size:11px;cursor:pointer}
.pre button[aria-pressed=true]{background:var(--accent);color:var(--accent-ink);border-color:var(--accent)}
.bx{width:min(330px,100%);display:grid;gap:9px}.rw{display:grid;gap:3px;font-size:11.5px;color:var(--muted)}.rw b{color:var(--text);font-weight:600}input[type=range]{width:100%;accent-color:#171717}
.out{font-size:12px;color:var(--muted);line-height:1.4}.out b{color:var(--text)}
button:focus-visible,input:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.wr{position:relative;padding-bottom:140px}.tg{display:flex;align-items:center;gap:8px;justify-content:space-between;width:190px;height:36px;padding:0 12px;border:1px solid var(--line);border-radius:10px;background:var(--surface);font-size:13px;font-weight:600}.tg i{font-style:normal;font-size:11px}.lb{position:absolute;left:0;top:42px;width:100%;max-width:300px;list-style:none;background:#fff;border:1px solid var(--line);border-radius:12px;box-shadow:0 10px 24px rgba(0,0,0,.14);padding:4px;z-index:4;animation:fi .12s}.lb li{display:grid;grid-template-columns:1fr auto;gap:2px 10px;padding:7px 9px;border-radius:8px;cursor:pointer;font-size:12.5px;outline:none}.lb li b{font-size:13px}.lb li small{grid-column:1;color:var(--muted);font-size:11.5px}.lb li .mt{grid-column:2;grid-row:1/3;align-self:center;font-size:10px;color:#555;display:grid;gap:2px;text-align:right}.lb li[aria-selected=true] b::after{content:" \2713"}.lb li:hover,.lb li:focus{background:#f1f1ee}.lb li:focus{box-shadow:inset 0 0 0 2px #2f6bff}.d{letter-spacing:1px}@keyframes fi{from{opacity:0}}.out{font-size:12px;color:var(--muted);min-height:16px;margin:0}@media (prefers-reduced-motion:reduce){.lb{animation:none}}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}const M=[['Fast','Quick answers for simple tasks.',3,1,'Low cost'],['Balanced','Good all-round quality and speed.',2,2,'Medium cost'],['Deep','Best for hard reasoning and long work.',1,3,'Higher cost']],tg=document.getElementById('tg'),lb=document.getElementById('lb'),cur=document.getElementById('cur'),out=document.getElementById('out');let sel=1;
const dots=n=>'\u25CF'.repeat(n)+'\u25CB'.repeat(3-n);
function render(){lb.innerHTML=M.map((m,i)=>'<li role="option" tabindex="-1" data-i="'+i+'" aria-selected="'+(i===sel)+'"><b>'+m[0]+'</b><span class="mt"><span>Speed <span class="d">'+dots(m[2])+'</span></span><span>Depth <span class="d">'+dots(m[3])+'</span></span></span><small>'+m[1]+' '+m[4]+'.</small></li>').join('');}
function open(){render();lb.hidden=false;tg.setAttribute('aria-expanded','true');lb.children[sel].focus();}
function close(f){lb.hidden=true;tg.setAttribute('aria-expanded','false');if(f)tg.focus();}
function pick(i){sel=i;cur.textContent=M[i][0];out.textContent='Model set to '+M[i][0]+'.';close(true);}
tg.addEventListener('click',()=>lb.hidden?open():close(true));tg.addEventListener('keydown',e=>{if(e.key==='ArrowDown'&&lb.hidden){e.preventDefault();open();}});
lb.addEventListener('click',e=>{const li=e.target.closest('li');if(li)pick(+li.dataset.i);});
lb.addEventListener('keydown',e=>{const items=[...lb.children],i=items.indexOf(document.activeElement);if(e.key==='ArrowDown'){e.preventDefault();items[Math.min(items.length-1,i+1)].focus();}else if(e.key==='ArrowUp'){e.preventDefault();items[Math.max(0,i-1)].focus();}else if(e.key==='Home'){e.preventDefault();items[0].focus();}else if(e.key==='End'){e.preventDefault();items[items.length-1].focus();}else if(e.key==='Enter'||e.key===' '){e.preventDefault();if(i>=0)pick(i);}else if(e.key==='Escape'){e.preventDefault();close(true);}else if(e.key==='Tab'){close(false);}});
document.addEventListener('click',e=>{if(!lb.hidden&&!e.target.closest('.wr'))close(false);});One complete HTML file. Save it and open it in a browser.
<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Model Picker with Descriptions — demo</title>
<style>
:root{--bg:#F1F1EF;--surface:#fff;--surface-2:#F7F7F5;--line:#E0E0DC;--text:#171717;--muted:#6f6f6f;--accent:#171717;--accent-ink:#fff;--danger:#d92d20}
*{box-sizing:border-box;margin:0}
html,body{height:100%}body{background:var(--bg);color:var(--text);font:15px/1.5 -apple-system,BlinkMacSystemFont,'Segoe UI',Inter,Roboto,sans-serif;-webkit-font-smoothing:antialiased}.stage{min-height:100%;display:grid;place-items:center;padding:24px}button,input,select,textarea{font-family:inherit}@media (prefers-reduced-motion:reduce){html{scroll-behavior:auto}}
button{font:inherit;color:inherit;background:none;border:0;padding:0;cursor:pointer}a{color:inherit;text-decoration:none}ul,ol,p,h4{margin:0;padding:0}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
.pre{display:flex;gap:5px;flex-wrap:wrap}.pre button{height:28px;padding:0 11px;border-radius:99px;border:1px solid var(--line);background:var(--surface);font-size:11px;cursor:pointer}
.pre button[aria-pressed=true]{background:var(--accent);color:var(--accent-ink);border-color:var(--accent)}
.bx{width:min(330px,100%);display:grid;gap:9px}.rw{display:grid;gap:3px;font-size:11.5px;color:var(--muted)}.rw b{color:var(--text);font-weight:600}input[type=range]{width:100%;accent-color:#171717}
.out{font-size:12px;color:var(--muted);line-height:1.4}.out b{color:var(--text)}
button:focus-visible,input:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.wr{position:relative;padding-bottom:140px}.tg{display:flex;align-items:center;gap:8px;justify-content:space-between;width:190px;height:36px;padding:0 12px;border:1px solid var(--line);border-radius:10px;background:var(--surface);font-size:13px;font-weight:600}.tg i{font-style:normal;font-size:11px}.lb{position:absolute;left:0;top:42px;width:100%;max-width:300px;list-style:none;background:#fff;border:1px solid var(--line);border-radius:12px;box-shadow:0 10px 24px rgba(0,0,0,.14);padding:4px;z-index:4;animation:fi .12s}.lb li{display:grid;grid-template-columns:1fr auto;gap:2px 10px;padding:7px 9px;border-radius:8px;cursor:pointer;font-size:12.5px;outline:none}.lb li b{font-size:13px}.lb li small{grid-column:1;color:var(--muted);font-size:11.5px}.lb li .mt{grid-column:2;grid-row:1/3;align-self:center;font-size:10px;color:#555;display:grid;gap:2px;text-align:right}.lb li[aria-selected=true] b::after{content:" \2713"}.lb li:hover,.lb li:focus{background:#f1f1ee}.lb li:focus{box-shadow:inset 0 0 0 2px #2f6bff}.d{letter-spacing:1px}@keyframes fi{from{opacity:0}}.out{font-size:12px;color:var(--muted);min-height:16px;margin:0}@media (prefers-reduced-motion:reduce){.lb{animation:none}}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}
</style></head>
<body><div class="stage">
<div class="bx"><div class="wr"><button class="tg" id="tg" type="button" aria-haspopup="listbox" aria-expanded="false" aria-controls="lb"><span id="cur">Balanced</span><i>▾</i></button><ul class="lb" id="lb" role="listbox" aria-label="Model" tabindex="-1" hidden></ul></div><p class="out" id="out" role="status"></p></div>
</div>
<script>
const M=[['Fast','Quick answers for simple tasks.',3,1,'Low cost'],['Balanced','Good all-round quality and speed.',2,2,'Medium cost'],['Deep','Best for hard reasoning and long work.',1,3,'Higher cost']],tg=document.getElementById('tg'),lb=document.getElementById('lb'),cur=document.getElementById('cur'),out=document.getElementById('out');let sel=1;
const dots=n=>'\u25CF'.repeat(n)+'\u25CB'.repeat(3-n);
function render(){lb.innerHTML=M.map((m,i)=>'<li role="option" tabindex="-1" data-i="'+i+'" aria-selected="'+(i===sel)+'"><b>'+m[0]+'</b><span class="mt"><span>Speed <span class="d">'+dots(m[2])+'</span></span><span>Depth <span class="d">'+dots(m[3])+'</span></span></span><small>'+m[1]+' '+m[4]+'.</small></li>').join('');}
function open(){render();lb.hidden=false;tg.setAttribute('aria-expanded','true');lb.children[sel].focus();}
function close(f){lb.hidden=true;tg.setAttribute('aria-expanded','false');if(f)tg.focus();}
function pick(i){sel=i;cur.textContent=M[i][0];out.textContent='Model set to '+M[i][0]+'.';close(true);}
tg.addEventListener('click',()=>lb.hidden?open():close(true));tg.addEventListener('keydown',e=>{if(e.key==='ArrowDown'&&lb.hidden){e.preventDefault();open();}});
lb.addEventListener('click',e=>{const li=e.target.closest('li');if(li)pick(+li.dataset.i);});
lb.addEventListener('keydown',e=>{const items=[...lb.children],i=items.indexOf(document.activeElement);if(e.key==='ArrowDown'){e.preventDefault();items[Math.min(items.length-1,i+1)].focus();}else if(e.key==='ArrowUp'){e.preventDefault();items[Math.max(0,i-1)].focus();}else if(e.key==='Home'){e.preventDefault();items[0].focus();}else if(e.key==='End'){e.preventDefault();items[items.length-1].focus();}else if(e.key==='Enter'||e.key===' '){e.preventDefault();if(i>=0)pick(i);}else if(e.key==='Escape'){e.preventDefault();close(true);}else if(e.key==='Tab'){close(false);}});
document.addEventListener('click',e=>{if(!lb.hidden&&!e.target.closest('.wr'))close(false);});
</script>
</body></html>