Month Switcher Slide
A copy-paste calendars & date pickers component in pure HTML, CSS & vanilla JS. Zero dependencies, framework-agnostic, MIT-licensed.
Calendars & Date PickersHTMLJavaScriptCSSany framework
Copy into your project
HTML
<div class="nuda-monthslide">
<button aria-label="Previous">‹</button>
<div class="nuda-monthslide__viewport">
<div class="nuda-monthslide__track">
<span>April</span>
<span>May</span>
<span class="is-active">June</span>
<span>July</span>
<span>August</span>
</div>
</div>
<button aria-label="Next">›</button>
</div>JavaScript
const root = document.querySelector('.nuda-monthslide');
const track = root.querySelector('.nuda-monthslide__track');
const items = root.querySelectorAll('.nuda-monthslide__track span');
const [prev, next] = root.querySelectorAll('button');
let index = [...items].findIndex(s => s.classList.contains('is-active'));
const SLOT = 90;
const update = () => {
items.forEach(i => i.classList.remove('is-active'));
items[index].classList.add('is-active');
track.style.transform = `translateX(${-index * SLOT}px)`;
};
prev.onclick = () => { index = Math.max(0, index - 1); update(); };
next.onclick = () => { index = Math.min(items.length - 1, index + 1); update(); };CSS
.nuda-monthslide {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 6px;
background: rgba(255,255,255,.02);
border: 1px solid rgba(255,255,255,.06);
border-radius: 12px;
}
.nuda-monthslide button {
background: rgba(255,255,255,.04);
border: 1px solid rgba(255,255,255,.08);
color: #fafafa;
width: 24px;
height: 28px;
border-radius: 6px;
cursor: pointer;
transition: background .2s,transform .2s;
}
.nuda-monthslide button:hover {
background: #e4ff54;
color: #09090b;
transform: translateY(-1px);
}
.nuda-monthslide__viewport {
overflow: hidden;
width: 90px;
}
.nuda-monthslide__track {
display: flex;
transform: translateX(-180px);
transition: transform .55s cubic-bezier(.16,1,.3,1);
}
.nuda-monthslide__track span {
flex-shrink: 0;
width: 90px;
text-align: center;
color: #63636e;
font-size: 12px;
font-weight: 500;
transition: color .35s;
}
.nuda-monthslide__track span.is-active {
color: #e4ff54;
font-weight: 700;
}
How to use Month Switcher Slide
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.