Segmented Control
A copy-paste mobile patterns component in pure HTML & CSS. Zero dependencies, framework-agnostic, MIT-licensed.
Mobile PatternsHTMLCSSany framework
Copy into your project
HTML
<div class="nuda-seg" role="tablist" aria-label="View">
<div class="nuda-seg__indicator" aria-hidden="true"></div>
<button type="button" class="nuda-seg__btn nuda-seg__btn--active" role="tab" aria-selected="true">Day</button>
<button type="button" class="nuda-seg__btn" role="tab" aria-selected="false">Week</button>
<button type="button" class="nuda-seg__btn" role="tab" aria-selected="false">Month</button>
</div>CSS
/* Segmented Control
Pill-style switch with a sliding indicator.
Customize: --seg-bg, --seg-pill */
.nuda-seg {
--seg-bg: rgba(255, 255, 255, 0.06);
--seg-pill: #111114;
position: relative;
display: flex;
width: 260px;
padding: 3px;
background: var(--seg-bg);
border: 1px solid rgba(255, 255, 255, 0.06);
border-radius: 10px;
font-family: system-ui;
}
.nuda-seg__indicator {
position: absolute;
top: 3px;
bottom: 3px;
left: 3px;
width: calc((100% - 6px) / 3);
background: var(--seg-pill);
border-radius: 8px;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
animation: nuda-seg-slide 4s cubic-bezier(0.5, 1.4, 0.5, 1) infinite;
will-change: transform;
}
.nuda-seg__btn {
position: relative;
z-index: 1;
flex: 1;
appearance: none;
background: transparent;
border: 0;
color: #a0a0a8;
font: 600 12px/1 system-ui;
min-height: 32px;
cursor: pointer;
transition: color 0.25s;
}
.nuda-seg__btn--active { color: #fafafa; }
@keyframes nuda-seg-slide {
0%, 25% { transform: translateX(0); }
33%, 58% { transform: translateX(100%); }
66%, 91% { transform: translateX(200%); }
100% { transform: translateX(0); }
}
@media (prefers-reduced-motion: reduce) {
.nuda-seg__indicator { animation: none; }
}How to use Segmented Control
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.