AI Confidence Highlighting
An AI answer where uncertain claims can be highlighted, with a note on each explaining what to verify.
AI prompt
Clean UI mockup of an AI answer paragraph in a chat interface with some phrases marked by confidence: most text plain, one phrase with a dotted amber underline labelled Check, one phrase with a stronger red dotted underline labelled Low confidence, below the paragraph a small card explaining Sources disagree on this figure with a button View sources, a switch at the top labelled Show confidence turned on, light theme, flat modern style, calm and trustworthy. Negative: fake percentages, red alert banners, robots, text errors, clutter. Reduced motion: static design.About this pattern
Definition
AI answers mix well-supported statements with guesses, and a smooth paragraph hides the difference. Highlighting claims by confidence, with a short note on why and what to check, helps people decide where to verify instead of trusting or distrusting the whole answer.
Purpose & UX principles
- Mark uncertain claims with an underline and a clear label, not just colour.
- Offer a short reason: no source found, sources disagree, or the figure is estimated.
- Keep high-confidence text unmarked so the warnings stay meaningful.
- Link each flagged claim to a way to check it.
Interaction states
- A Show confidence switch and clickable claims with a detail panel.
Motion specification
- Highlights appear instantly.
- Reduced motion: nothing animates.
Responsive behaviour
- Do not display fake precision such as a percentage unless it is calibrated.
- Make the highlight optional so the answer stays readable.
Code
<div class="bx"><label class="sw"><input id="sw" type="checkbox" checked> Show confidence</label><p class="an" id="an"></p><div class="dt" id="dt" role="status">Select a highlighted claim for details.</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}
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}
.an{font-size:13px;line-height:1.85;border:1px solid var(--line);border-radius:12px;background:var(--surface);padding:10px 12px}.an button{font:inherit;color:inherit;display:inline;padding:0;text-align:left;cursor:pointer}.an.on button.m{border-bottom:2px dotted #d99a00;background:rgba(255,190,0,.12)}.an.on button.l{border-bottom:2px dotted #d33;background:rgba(220,50,50,.1)}.an.on button.m::after{content:" \2022 check";font-size:9.5px;color:#a06a00;font-weight:700}.an.on button.l::after{content:" \2022 low";font-size:9.5px;color:#c62f2f;font-weight:700}.dt{border:1px solid var(--line);border-radius:10px;background:var(--pv);padding:8px 10px;font-size:12px;color:var(--muted);min-height:40px}.dt b{color:var(--text)}.sw{display:flex;gap:6px;align-items:center;font-size:12px;color:var(--muted)}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}const S=[['The company was founded in 2011 ',0],['and now employs about 4,000 people',1,'The figure comes from a 2022 article. Newer sources were not found.'],[', with its headquarters in Lisbon. ',0],['Revenue reached 1.2 billion euros last year',2,'Sources disagree: two reports give different totals. Verify before quoting.'],[', and the product is available in 40 countries.',0]],an=document.getElementById('an'),sw=document.getElementById('sw'),dt=document.getElementById('dt');
an.innerHTML=S.map((s,i)=>s[1]?'<button type="button" class="'+(s[1]===1?'m':'l')+'" data-i="'+i+'">'+s[0]+'</button>':s[0]).join('');
function up(){an.classList.toggle('on',sw.checked);}
an.addEventListener('click',e=>{const b=e.target.closest('button');if(!b)return;const s=S[+b.dataset.i];dt.innerHTML='<b>'+(s[1]===1?'Check this claim':'Low confidence')+':</b> '+s[2];});sw.addEventListener('change',up);up();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>AI Confidence Highlighting — 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}
.an{font-size:13px;line-height:1.85;border:1px solid var(--line);border-radius:12px;background:var(--surface);padding:10px 12px}.an button{font:inherit;color:inherit;display:inline;padding:0;text-align:left;cursor:pointer}.an.on button.m{border-bottom:2px dotted #d99a00;background:rgba(255,190,0,.12)}.an.on button.l{border-bottom:2px dotted #d33;background:rgba(220,50,50,.1)}.an.on button.m::after{content:" \2022 check";font-size:9.5px;color:#a06a00;font-weight:700}.an.on button.l::after{content:" \2022 low";font-size:9.5px;color:#c62f2f;font-weight:700}.dt{border:1px solid var(--line);border-radius:10px;background:var(--pv);padding:8px 10px;font-size:12px;color:var(--muted);min-height:40px}.dt b{color:var(--text)}.sw{display:flex;gap:6px;align-items:center;font-size:12px;color:var(--muted)}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}
</style></head>
<body><div class="stage">
<div class="bx"><label class="sw"><input id="sw" type="checkbox" checked> Show confidence</label><p class="an" id="an"></p><div class="dt" id="dt" role="status">Select a highlighted claim for details.</div></div>
</div>
<script>
const S=[['The company was founded in 2011 ',0],['and now employs about 4,000 people',1,'The figure comes from a 2022 article. Newer sources were not found.'],[', with its headquarters in Lisbon. ',0],['Revenue reached 1.2 billion euros last year',2,'Sources disagree: two reports give different totals. Verify before quoting.'],[', and the product is available in 40 countries.',0]],an=document.getElementById('an'),sw=document.getElementById('sw'),dt=document.getElementById('dt');
an.innerHTML=S.map((s,i)=>s[1]?'<button type="button" class="'+(s[1]===1?'m':'l')+'" data-i="'+i+'">'+s[0]+'</button>':s[0]).join('');
function up(){an.classList.toggle('on',sw.checked);}
an.addEventListener('click',e=>{const b=e.target.closest('button');if(!b)return;const s=S[+b.dataset.i];dt.innerHTML='<b>'+(s[1]===1?'Check this claim':'Low confidence')+':</b> '+s[2];});sw.addEventListener('change',up);up();
</script>
</body></html>