Skip to content

Slider + Number Input

A copy-paste sliders & ranges component in pure HTML, CSS & vanilla JS. Zero dependencies, framework-agnostic, MIT-licensed.

Sliders & RangesHTMLJavaScriptCSSany framework
%

Copy into your project

HTML
<div class="nuda-sinput">
  <div class="nuda-sinput__track">
    <div class="nuda-sinput__fill" style="width:30%"></div>
    <div class="nuda-sinput__thumb" style="left:30%"></div>
  </div>
  <input type="number" value="30" min="0" max="100" />
  <span class="nuda-sinput__unit">%</span>
</div>
JavaScript
const root = document.querySelector('.nuda-sinput');
const fill = root.querySelector('.nuda-sinput__fill');
const thumb = root.querySelector('.nuda-sinput__thumb');
const input = root.querySelector('input');

const sync = (v) => {
  const c = Math.max(0, Math.min(100, +v));
  fill.style.width = c + '%';
  thumb.style.left = c + '%';
  input.value = c;
};

input.addEventListener('input', () => sync(input.value));
CSS
.nuda-sinput {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(255,255,255,.02);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 12px;
  width: 100%;
  max-width: 260px;
}

.nuda-sinput__track {
  flex: 1;
  position: relative;
  height: 4px;
  background: rgba(255,255,255,.08);
  border-radius: 99px;
}

.nuda-sinput__fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background: #e4ff54;
  border-radius: 99px;
  transition: width .35s cubic-bezier(.16,1,.3,1);
}

.nuda-sinput__thumb {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #e4ff54;
  transform: translate(-50%,-50%);
  cursor: grab;
  transition: left .35s cubic-bezier(.16,1,.3,1);
}

.nuda-sinput input {
  width: 46px;
  padding: 4px 6px;
  background: rgba(0,0,0,.3);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 6px;
  color: #fafafa;
  font-size: 12px;
  text-align: center;
  outline: none;
  font-variant-numeric: tabular-nums;
  transition: border-color .2s,box-shadow .25s;
  -moz-appearance: textfield;
  appearance: textfield;
}

.nuda-sinput input::-webkit-outer-spin-button,.nuda-sinput input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.nuda-sinput input:focus {
  border-color: #e4ff54;
  box-shadow: 0 0 0 3px rgba(228,255,84,.15);
}

.nuda-sinput__unit {
  color: #63636e;
  font-size: 11px;
}

How to use Slider + Number Input

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.

More sliders & ranges components

← Browse all NudaUI components