Icon Stroke Style Controls
Three line icons that change together as you adjust stroke weight, line cap, corner join and fill.
AI prompt
Icon set sheet: three line icons (a house, a heart and a bell) drawn on a 24 pixel grid with a consistent 2 pixel stroke, round line caps and round joins, dark charcoal on a pale background, evenly spaced in a row, with small labels below each, flat vector style, no fill, no shadow. Variants: a thicker 3 pixel stroke, square caps with sharp mitre joins, and a filled version. Negative: mixed stroke weights, gradients, perspective, text errors, decorative frames. Reduced motion: static sheet.About this pattern
Definition
A line icon set looks consistent when every icon shares the same stroke weight, end caps and corner style. Round caps and joins feel friendly; butt caps and miter joins feel precise and technical. One CSS variable per property can restyle a whole set.
When to use it
- Choose one stroke weight (1.5 or 2px on a 24px grid) and keep it everywhere.
- Round caps and joins for friendly products; square for technical ones.
- Never mix filled and outline icons in the same row.
What the controls do
- A Weight slider, Cap and Join buttons and a Fill checkbox.
Motion & timing
- Changes are instant; no animation.
- Reduced motion: nothing to change.
Tips & variations
- Scale the stroke with the icon; at 16px use 1.5, at 32px use 2 or more.
- Keep icons on the same grid with the same padding.
Code of this live preview
<div class="bx"><div class="ic" id="ic"><svg viewBox="0 0 24 24" width="64" height="64" aria-hidden="true"><path d="M3 11l9-8 9 8v10H3z"/><path d="M9 21v-7h6v7"/></svg><svg viewBox="0 0 24 24" width="64" height="64" aria-hidden="true"><path d="M12 21s-8-5.2-8-11a4.5 4.5 0 0 1 8-2.8A4.5 4.5 0 0 1 20 10c0 5.8-8 11-8 11z"/></svg><svg viewBox="0 0 24 24" width="64" height="64" aria-hidden="true"><path d="M6 17V11a6 6 0 0 1 12 0v6l2 2H4z"/><path d="M10 21a2 2 0 0 0 4 0"/></svg></div><label class="rw">Weight <b id="wv">2</b><input id="wt" type="range" min="1" max="4" step=".5" value="2"></label><div class="two"><div class="pre" id="cp" role="group" aria-label="Line cap"><button data-v="round" aria-pressed="true">Round cap</button><button data-v="butt" aria-pressed="false">Butt cap</button></div><div class="pre" id="jn" role="group" aria-label="Line join"><button data-v="round" aria-pressed="true">Round join</button><button data-v="miter" aria-pressed="false">Miter join</button></div></div><label class="sw"><input id="fl" type="checkbox"> Fill</label></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}
.ic{display:flex;justify-content:space-around;padding:12px;border-radius:12px;background:var(--surface);border:1px solid var(--line)}.ic svg{fill:var(--f,none);stroke:#222;stroke-width:var(--w);stroke-linecap:var(--c);stroke-linejoin:var(--j)}
.two{display:flex;gap:10px;flex-wrap:wrap}.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 ic=document.getElementById('ic'),wt=document.getElementById('wt'),fl=document.getElementById('fl');let cap='round',jn='round';
function up(){ic.style.setProperty('--w',wt.value);ic.style.setProperty('--c',cap);ic.style.setProperty('--j',jn);ic.style.setProperty('--f',fl.checked?'#cfd4dc':'none');document.getElementById('wv').textContent=wt.value;[...document.querySelectorAll('#cp button')].forEach(b=>b.setAttribute('aria-pressed',String(b.dataset.v===cap)));[...document.querySelectorAll('#jn button')].forEach(b=>b.setAttribute('aria-pressed',String(b.dataset.v===jn)));}
document.querySelectorAll('#cp button').forEach(b=>b.addEventListener('click',()=>{cap=b.dataset.v;up();}));document.querySelectorAll('#jn button').forEach(b=>b.addEventListener('click',()=>{jn=b.dataset.v;up();}));wt.addEventListener('input',up);fl.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>Icon Stroke Style Controls — 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}
.ic{display:flex;justify-content:space-around;padding:12px;border-radius:12px;background:var(--surface);border:1px solid var(--line)}.ic svg{fill:var(--f,none);stroke:#222;stroke-width:var(--w);stroke-linecap:var(--c);stroke-linejoin:var(--j)}
.two{display:flex;gap:10px;flex-wrap:wrap}.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"><div class="ic" id="ic"><svg viewBox="0 0 24 24" width="64" height="64" aria-hidden="true"><path d="M3 11l9-8 9 8v10H3z"/><path d="M9 21v-7h6v7"/></svg><svg viewBox="0 0 24 24" width="64" height="64" aria-hidden="true"><path d="M12 21s-8-5.2-8-11a4.5 4.5 0 0 1 8-2.8A4.5 4.5 0 0 1 20 10c0 5.8-8 11-8 11z"/></svg><svg viewBox="0 0 24 24" width="64" height="64" aria-hidden="true"><path d="M6 17V11a6 6 0 0 1 12 0v6l2 2H4z"/><path d="M10 21a2 2 0 0 0 4 0"/></svg></div><label class="rw">Weight <b id="wv">2</b><input id="wt" type="range" min="1" max="4" step=".5" value="2"></label><div class="two"><div class="pre" id="cp" role="group" aria-label="Line cap"><button data-v="round" aria-pressed="true">Round cap</button><button data-v="butt" aria-pressed="false">Butt cap</button></div><div class="pre" id="jn" role="group" aria-label="Line join"><button data-v="round" aria-pressed="true">Round join</button><button data-v="miter" aria-pressed="false">Miter join</button></div></div><label class="sw"><input id="fl" type="checkbox"> Fill</label></div>
</div>
<script>
const ic=document.getElementById('ic'),wt=document.getElementById('wt'),fl=document.getElementById('fl');let cap='round',jn='round';
function up(){ic.style.setProperty('--w',wt.value);ic.style.setProperty('--c',cap);ic.style.setProperty('--j',jn);ic.style.setProperty('--f',fl.checked?'#cfd4dc':'none');document.getElementById('wv').textContent=wt.value;[...document.querySelectorAll('#cp button')].forEach(b=>b.setAttribute('aria-pressed',String(b.dataset.v===cap)));[...document.querySelectorAll('#jn button')].forEach(b=>b.setAttribute('aria-pressed',String(b.dataset.v===jn)));}
document.querySelectorAll('#cp button').forEach(b=>b.addEventListener('click',()=>{cap=b.dataset.v;up();}));document.querySelectorAll('#jn button').forEach(b=>b.addEventListener('click',()=>{jn=b.dataset.v;up();}));wt.addEventListener('input',up);fl.addEventListener('change',up);up();
</script>
</body></html>