Pill toggle switch

Open in editor
body { margin: 0; min-height: 100vh; display: grid; place-items: center; background: #16171a; color: #ecebe6; font: 16px system-ui, sans-serif; }
.switch { --on: #c8f560; display: inline-flex; align-items: center; gap: 12px; cursor: pointer; }
.switch input { appearance: none; margin: 0; width: 52px; height: 30px; border-radius: 999px; background: #34373f; position: relative; cursor: pointer; transition: background .2s; }
.switch input::before { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s cubic-bezier(.3,1.4,.6,1); }
.switch input:checked { background: var(--on); }
.switch input:checked::before { transform: translateX(22px); background: #13180a; }
.switch input:focus-visible { outline: 2px solid var(--on); outline-offset: 3px; }

Usage

Keep the native `<input type=checkbox role=switch>`. Track color is `--on`.