Readout bar
Top bar with a scroll gauge and percentage, arrow links, an outlined contact box and a pill toggle.
Part of the style
Pewter Haze Readout
7 parts that belong together, with their tokens, type and rules.
https://kitbash.me/components/pewter-haze-readout/hud/figma.html?palette=badb825c54a0c19e
Use the Figma MCP server (https://mcp.figma.com/mcp). Download https://kitbash.me/components/pewter-haze-readout/hud/figma.html?palette=badb825c54a0c19e and pass that whole HTML document to the html_to_figma tool, so the part "Readout bar" lands as editable layers in my open Figma file. Fonts come from Google Fonts: if a face is missing in Figma, pick the closest one.
Code
<style>
/* Goes after the pack's base.css */
:root {
--fog-core: #b4b3b3;
--fog-mid: #e9e9e9;
--fog-edge: #ffffff;
--night: #ffffff;
--ink: #363736;
--ink-soft: rgba(54, 55, 54, 0.62);
--ink-faint: rgba(54, 55, 54, 0.28);
--veil: rgba(54, 55, 54, 0.08);
--shade: rgba(255, 255, 255, 0.35);
--iris-a: #198d75;
--iris-b: #198d75;
--iris-c: #4bb299;
--iris-d: #198d75;
}
</style>
<header class="hud">
<div class="hud__gauge" role="progressbar" aria-label="Page scrolled" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0">
<span class="hud__track"><span class="hud__fill"></span></span>
<span class="hud__count">0%</span>
</div>
<button class="hud__toggle" type="button" aria-pressed="false" aria-label="Sound">
<span class="hud__knob"></span>
</button>
<div class="hud__side">
<p class="hud__stack">Glass · Sound · Light · Code</p>
<nav class="hud__links" aria-label="Elsewhere">
<a class="hud__link" href="#" data-text="Journal">Journal</a>
<a class="hud__link" href="#" data-text="Archive">Archive</a>
</nav>
<a class="hud__contact" href="#" data-text="Contact">Contact</a>
</div>
</header>
<style>
.hud {
position: sticky;
top: 0;
z-index: 5;
display: grid;
grid-template-columns: 1fr auto 1fr;
align-items: start;
gap: var(--gap);
padding: var(--space-s) var(--edge);
}
.hud__gauge {
display: grid;
justify-items: start;
gap: var(--space-xs);
width: min(15rem, 100%);
}
.hud__track {
position: relative;
width: 100%;
height: 10px;
border: var(--line) solid var(--ink);
}
.hud__fill {
position: absolute;
inset: 2px auto 2px 2px;
width: calc((100% - 4px) * var(--progress, 0));
background: var(--ink-soft);
}
.hud__count {
margin-left: calc(100% * var(--progress, 0));
translate: calc(-100% * var(--progress, 0)) 0;
font-size: var(--text-s);
font-weight: 700;
}
.hud__toggle {
position: relative;
width: 3.5rem;
height: var(--tap);
padding: 0;
border: 0;
background: none;
cursor: pointer;
}
.hud__toggle::before {
content: "";
position: absolute;
inset: 50% 0 auto;
height: 1.25rem;
translate: 0 -50%;
border: var(--line) solid var(--ink);
border-radius: var(--radius-round);
}
.hud__knob {
position: absolute;
top: 50%;
left: 0.25rem;
width: 0.875rem;
height: 0.875rem;
translate: 0 -50%;
border-radius: var(--radius-round);
background: var(--ink);
transition: left var(--quick) var(--ease);
}
.hud__toggle[aria-pressed="true"] .hud__knob { left: calc(100% - 1.125rem); }
.hud__toggle:focus-visible { outline: var(--line) solid var(--ink); outline-offset: 2px; }
.hud__side {
display: grid;
justify-items: end;
gap: var(--space-xs);
text-align: right;
}
.hud__stack { margin: 0; color: var(--ink-soft); }
.hud__links { display: flex; gap: var(--space-m); }
.hud__link {
display: inline-flex;
align-items: center;
min-height: var(--tap);
text-decoration: none;
}
.hud__link::after, .hud__contact::after { content: " \2197"; white-space: pre; }
.hud__contact::after { content: none; }
.hud__link:hover, .hud__link:focus-visible { text-decoration: underline; text-underline-offset: 3px; }
.hud__contact {
display: inline-flex;
align-items: center;
min-height: var(--tap);
padding: 0 var(--space-m);
border: var(--line) solid var(--ink);
border-radius: var(--radius);
text-decoration: none;
transition: background-color var(--quick) var(--ease), color var(--quick) var(--ease);
}
.hud__contact:hover, .hud__contact:focus-visible { background: var(--ink); color: var(--night); outline: none; }
@media (max-width: 40rem) {
.hud { grid-template-columns: 1fr auto auto; }
.hud__stack, .hud__links { display: none; }
}
</style>
<script>
(() => {
const glyphs = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789*/<>#';
const still = matchMedia('(prefers-reduced-motion: reduce)');
function scramble(el) {
if (still.matches) return;
const text = el.dataset.text;
let frame = 0;
clearInterval(el._timer);
el._timer = setInterval(() => {
frame += 1;
el.textContent = [...text].map((ch, i) => (i < frame / 2 ? ch : glyphs[Math.floor(Math.random() * glyphs.length)])).join('');
if (frame / 2 >= text.length) { clearInterval(el._timer); el.textContent = text; }
}, 28);
}
for (const root of document.querySelectorAll('.hud')) {
const gauge = root.querySelector('.hud__gauge');
const count = root.querySelector('.hud__count');
const update = () => {
const max = document.documentElement.scrollHeight - innerHeight;
const p = max > 0 ? Math.min(1, Math.max(0, scrollY / max)) : 0;
root.style.setProperty('--progress', p.toFixed(4));
count.textContent = Math.round(p * 100) + '%';
gauge.setAttribute('aria-valuenow', Math.round(p * 100));
};
addEventListener('scroll', update, { passive: true });
addEventListener('resize', update);
update();
root.querySelectorAll('[data-text]').forEach((el) => el.addEventListener('pointerenter', () => scramble(el)));
const toggle = root.querySelector('.hud__toggle');
toggle.addEventListener('click', () => toggle.setAttribute('aria-pressed', toggle.getAttribute('aria-pressed') === 'true' ? 'false' : 'true'));
}
})();
</script>