EFFECT №009

TOGGLE
SWITCH

オン・オフが滑らかに切り替わるトグル。状態の二項対立に物理的な手応えを与える、最小のマイクロインタラクション。

MICRO CSS

CUSTOMIZE

↻ LIVE PREVIEW

入力するとデモ・コード・AIプロンプトが全て即座に書き換わります。

OFF
CLICK THE SWITCH

CODE

01 / 02
.switch {
  position: relative;
  display: inline-block;
  width: 96px;
  height: 48px;
}

.switch input { opacity: 0; width: 0; height: 0; }

.switch .slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #E5E5E5;
  border: 1px solid #1A1A1A;
  transition: background 0.4s cubic-bezier(0.65, 0, 0.35, 1);
}

.switch .slider::before {
  content: '';
  position: absolute;
  height: 36px; width: 36px;
  left: 4px; bottom: 4px;
  background: #1A1A1A;
  transition: transform 0.4s cubic-bezier(0.65, 0, 0.35, 1);
}

.switch input:checked + .slider {
  background: #E91B89;
  border-color: #E91B89;
}

.switch input:checked + .slider::before {
  transform: translateX(48px);
  background: #FAFAFA;
}

.switch input:focus-visible + .slider {
  outline: 2px solid #E91B89;
  outline-offset: 4px;
}

@media (prefers-reduced-motion: reduce) {
  .switch .slider,
  .switch .slider::before { transition: none; }
}

AI PROMPT

02 / 02