Skip to content

Preference Row

A copy-paste settings & preferences component in pure HTML & CSS. Zero dependencies, framework-agnostic, MIT-licensed.

Settings & PreferencesHTMLCSSany framework
Marketing emails
Receive product updates and offers from us.

Copy into your project

HTML
<div class="nuda-pref-row">
  <div class="nuda-pref-row__text">
    <div class="nuda-pref-row__label">Marketing emails</div>
    <div class="nuda-pref-row__desc">Receive product updates and offers from us.</div>
  </div>
  <label class="nuda-pref-row__switch">
    <input type="checkbox" checked />
    <span></span>
  </label>
</div>
CSS
/* Preference Row
   A labeled row with description and a toggle switch.
   Customize: --row-bg, --row-border, --switch-on */

.nuda-pref-row {
  --row-bg: #0c0c10;
  --row-border: rgba(255, 255, 255, 0.06);
  --switch-on: #e4ff54;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--row-bg);
  border: 1px solid var(--row-border);
  border-radius: 12px;
  width: 100%;
  max-width: 480px;
}

.nuda-pref-row__text {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.nuda-pref-row__label {
  color: #fafafa;
  font-size: 0.875rem;
  font-weight: 500;
}

.nuda-pref-row__desc {
  color: #a0a0a8;
  font-size: 0.75rem;
  line-height: 1.4;
}

.nuda-pref-row__switch {
  position: relative;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
  cursor: pointer;
}

.nuda-pref-row__switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
  z-index: 1;
}

.nuda-pref-row__switch span {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  transition: background 0.25s ease;
}

.nuda-pref-row__switch span::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fafafa;
  border-radius: 50%;
  transition: transform 0.25s ease;
}

.nuda-pref-row__switch input:checked + span {
  background: var(--switch-on);
}

.nuda-pref-row__switch input:checked + span::after {
  transform: translateX(16px);
  background: #09090b;
}

@media (prefers-reduced-motion: reduce) {
  .nuda-pref-row__switch span,
  .nuda-pref-row__switch span::after {
    transition: none;
  }
}

How to use Preference Row

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 settings & preferences components

← Browse all NudaUI components