Distance Scale Bar
A copy-paste maps & locations component in pure HTML & CSS. Zero dependencies, framework-agnostic, MIT-licensed.
Maps & LocationsHTMLCSSany framework
Copy into your project
HTML
<div class="nuda-ml2-scalebar">
<div class="nuda-ml2-scalebar__map" aria-hidden="true">
<span class="nuda-ml2-scalebar__grid"></span>
</div>
<div class="nuda-ml2-scalebar__ruler" aria-hidden="true">
<span class="nuda-ml2-scalebar__seg"></span>
<span class="nuda-ml2-scalebar__seg nuda-ml2-scalebar__seg--alt"></span>
<span class="nuda-ml2-scalebar__seg"></span>
<span class="nuda-ml2-scalebar__seg nuda-ml2-scalebar__seg--alt"></span>
<span class="nuda-ml2-scalebar__sweep"></span>
</div>
<ul class="nuda-ml2-scalebar__labels">
<li>0</li>
<li>100 m</li>
<li>200 m</li>
</ul>
</div>CSS
.nuda-ml2-scalebar {
display: flex;
flex-direction: column;
align-items: center;
gap: 8px;
width: 240px;
max-width: 100%;
}
.nuda-ml2-scalebar__map {
position: relative;
width: 240px;
height: 90px;
border-radius: 10px;
overflow: hidden;
background: linear-gradient(135deg,#101014,#1a1a20);
border: 1px solid rgba(255,255,255,.06);
}
.nuda-ml2-scalebar__grid {
position: absolute;
inset: 0;
background-image: linear-gradient(90deg,rgba(255,255,255,.05) 1px,transparent 1px),linear-gradient(0deg,rgba(255,255,255,.05) 1px,transparent 1px);
background-size: 20px 20px;
}
.nuda-ml2-scalebar__ruler {
position: relative;
display: flex;
width: 200px;
height: 8px;
border-radius: 2px;
overflow: hidden;
background: #161616;
border: 1px solid rgba(255,255,255,.12);
}
.nuda-ml2-scalebar__seg {
flex: 1;
background: #2a2a30;
}
.nuda-ml2-scalebar__seg--alt {
background: #3a3a42;
}
.nuda-ml2-scalebar__sweep {
position: absolute;
top: 0;
left: 0;
width: 40px;
height: 100%;
background: linear-gradient(90deg,transparent,rgba(228,255,84,.8),transparent);
transform: translateX(-40px);
animation: _nuda-ml2scalebar-sweep 3s ease-in-out infinite;
}
.nuda-ml2-scalebar__labels {
display: flex;
justify-content: space-between;
width: 200px;
margin: 0;
padding: 0;
list-style: none;
font-size: 10px;
color: #777;
}
@keyframes _nuda-ml2scalebar-sweep {
0% {
transform: translateX(-40px);
}
100% {
transform: translateX(200px);
}
}
@media (prefers-reduced-motion:reduce) {
.nuda-ml2-scalebar__sweep {
animation: none !important;
opacity: 0;
}
}
How to use Distance Scale Bar
Paste the HTML where you need it and the CSS into a global stylesheet (or a <style> tag). Every class is prefixed nuda- so it never collides with Tailwind or your own styles. Tweak the CSS custom properties to match your design system.
Works in React, Vue, Svelte, Astro, Next.js, Nuxt, Laravel Blade, Django, Rails — or a single .html file. No npm install, no build step.