Citation Source Chips
An AI answer with numbered source chips; focus, hover or tap one to see the source card.
AI prompt
Clean UI mockup of an AI answer paragraph with three small numbered chips inline after the claims, rounded grey pills with the numbers 1 2 3, and a hover card open below chip 2: a white card with the source title, a small site name with a favicon circle, and a two-line quotation, soft shadow, thin border, flat modern style, light theme. Negative: footnote numbers at the page bottom, heavy borders, gradients, text errors, clutter. Reduced motion: static card.About this pattern
Definition
Citations tie each claim in an answer to where it came from. Small numbered chips sit inline, and a card with the source title, site and quote appears on hover, focus or tap. It lets readers check the answer without leaving it.
Purpose & UX principles
- Place the chip directly after the claim it supports, not at the end of the paragraph.
- Show title, publisher and a short quote in the card; link out only from the card.
- Make the chips real buttons so keyboard and touch users can open them.
Interaction states
- Three chips in a paragraph; hover, focus or tap opens the card; Escape closes it.
Motion specification
- The card fades in over 150ms.
- Reduced motion: it appears without fading.
Responsive behaviour
- On touch, a tap opens the card and a second tap or Escape closes it.
- Do not cover the sentence being cited with the card.
Code
<div class="bx"><p class="an">Global solar capacity grew by about 30% last year<button class="cc" data-i="0" aria-expanded="false">1</button>, and module prices fell to record lows<button class="cc" data-i="1" aria-expanded="false">2</button>. Most new projects were built in Asia<button class="cc" data-i="2" aria-expanded="false">3</button>.</p><div class="cd" id="cd" role="region" aria-live="polite" hidden></div></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}
.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}
.an{font-size:13.5px;line-height:1.7;padding:12px 14px;border:1px solid var(--line);border-radius:12px;background:var(--surface)}
.cc{display:inline-grid;place-items:center;min-width:20px;height:20px;margin:0 2px;padding:0 5px;border-radius:99px;background:var(--pv);border:1px solid var(--line);font-size:11px;font-weight:600;vertical-align:1px;cursor:pointer}.cc[aria-expanded=true],.cc:hover{background:#171717;color:#fff;border-color:#171717}
.cd{border:1px solid var(--line);border-radius:12px;background:var(--surface);box-shadow:0 8px 20px rgba(0,0,0,.1);padding:10px 12px;font-size:12px;animation:fi .15s}.cd[hidden]{display:none}.cd b{display:block;font-size:12.5px}.cd small{color:var(--muted);display:block;margin:1px 0 4px}.cd q{color:#444;display:block;line-height:1.4}
@keyframes fi{from{opacity:0}to{opacity:1}}@media (prefers-reduced-motion:reduce){.cd{animation:none}}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}const SRC=[['Solar Market Outlook','energy-report.example','\u201CAnnual installations rose by roughly 30 percent compared with the previous year.\u201D'],['Module Price Index','pricewatch.example','\u201CAverage module prices dropped to the lowest level ever recorded.\u201D'],['Regional Deployment Review','grid-analysis.example','\u201CAsia accounted for the majority of newly commissioned capacity.\u201D']],cd=document.getElementById('cd'),cc=[...document.querySelectorAll('.cc')];let cur=-1;
function open(i){cur=i;const s=SRC[i];cd.hidden=false;cd.innerHTML='<b>'+s[0]+'</b><small>'+s[1]+'</small><q>'+s[2]+'</q>';cc.forEach((c,k)=>c.setAttribute('aria-expanded',String(k===i)));}
function close(){cur=-1;cd.hidden=true;cc.forEach(c=>c.setAttribute('aria-expanded','false'));}
cc.forEach((c,i)=>{c.addEventListener('mouseenter',()=>open(i));c.addEventListener('focus',()=>open(i));c.addEventListener('click',()=>{cur===i&&c.getAttribute('aria-expanded')==='true'&&matchMedia('(hover:none)').matches?close():open(i);});});
document.addEventListener('keydown',e=>{if(e.key==='Escape')close();});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>Citation Source Chips — 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}}
.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}
.an{font-size:13.5px;line-height:1.7;padding:12px 14px;border:1px solid var(--line);border-radius:12px;background:var(--surface)}
.cc{display:inline-grid;place-items:center;min-width:20px;height:20px;margin:0 2px;padding:0 5px;border-radius:99px;background:var(--pv);border:1px solid var(--line);font-size:11px;font-weight:600;vertical-align:1px;cursor:pointer}.cc[aria-expanded=true],.cc:hover{background:#171717;color:#fff;border-color:#171717}
.cd{border:1px solid var(--line);border-radius:12px;background:var(--surface);box-shadow:0 8px 20px rgba(0,0,0,.1);padding:10px 12px;font-size:12px;animation:fi .15s}.cd[hidden]{display:none}.cd b{display:block;font-size:12.5px}.cd small{color:var(--muted);display:block;margin:1px 0 4px}.cd q{color:#444;display:block;line-height:1.4}
@keyframes fi{from{opacity:0}to{opacity:1}}@media (prefers-reduced-motion:reduce){.cd{animation:none}}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}
</style></head>
<body><div class="stage">
<div class="bx"><p class="an">Global solar capacity grew by about 30% last year<button class="cc" data-i="0" aria-expanded="false">1</button>, and module prices fell to record lows<button class="cc" data-i="1" aria-expanded="false">2</button>. Most new projects were built in Asia<button class="cc" data-i="2" aria-expanded="false">3</button>.</p><div class="cd" id="cd" role="region" aria-live="polite" hidden></div></div>
</div>
<script>
const SRC=[['Solar Market Outlook','energy-report.example','\u201CAnnual installations rose by roughly 30 percent compared with the previous year.\u201D'],['Module Price Index','pricewatch.example','\u201CAverage module prices dropped to the lowest level ever recorded.\u201D'],['Regional Deployment Review','grid-analysis.example','\u201CAsia accounted for the majority of newly commissioned capacity.\u201D']],cd=document.getElementById('cd'),cc=[...document.querySelectorAll('.cc')];let cur=-1;
function open(i){cur=i;const s=SRC[i];cd.hidden=false;cd.innerHTML='<b>'+s[0]+'</b><small>'+s[1]+'</small><q>'+s[2]+'</q>';cc.forEach((c,k)=>c.setAttribute('aria-expanded',String(k===i)));}
function close(){cur=-1;cd.hidden=true;cc.forEach(c=>c.setAttribute('aria-expanded','false'));}
cc.forEach((c,i)=>{c.addEventListener('mouseenter',()=>open(i));c.addEventListener('focus',()=>open(i));c.addEventListener('click',()=>{cur===i&&c.getAttribute('aria-expanded')==='true'&&matchMedia('(hover:none)').matches?close():open(i);});});
document.addEventListener('keydown',e=>{if(e.key==='Escape')close();});
</script>
</body></html>