Swap

Animated toggle between two elements with multiple transition effects — rotate, flip, fade, and slide.

This component requires softui.js for interactive behavior.

Default

<button class="sui-swap">
  <span class="sui-swap-on">
    <svg viewBox="0 0 24 24"><path d="M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z"/></svg>
  </span>
  <span class="sui-swap-off">
    <svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="5"/><line x1="12" y1="1" x2="12" y2="3"/><line x1="12" y1="21" x2="12" y2="23"/><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/><line x1="1" y1="12" x2="3" y2="12"/><line x1="21" y1="12" x2="23" y2="12"/><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/></svg>
  </span>
</button>

Rotate

<button class="sui-swap sui-swap-rotate">
  <span class="sui-swap-on">
    <svg viewBox="0 0 24 24"><path d="M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z"/></svg>
  </span>
  <span class="sui-swap-off">
    <svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="5"/><line x1="12" y1="1" x2="12" y2="3"/><line x1="12" y1="21" x2="12" y2="23"/><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/><line x1="1" y1="12" x2="3" y2="12"/><line x1="21" y1="12" x2="23" y2="12"/><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/></svg>
  </span>
</button>

Flip

<button class="sui-swap sui-swap-flip">
  <span class="sui-swap-on">
    <svg viewBox="0 0 24 24"><path d="M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z"/></svg>
  </span>
  <span class="sui-swap-off">
    <svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="5"/><line x1="12" y1="1" x2="12" y2="3"/><line x1="12" y1="21" x2="12" y2="23"/><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/><line x1="1" y1="12" x2="3" y2="12"/><line x1="21" y1="12" x2="23" y2="12"/><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/></svg>
  </span>
</button>

Fade

<button class="sui-swap sui-swap-fade">
  <span class="sui-swap-on">
    <svg viewBox="0 0 24 24"><path d="M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z"/></svg>
  </span>
  <span class="sui-swap-off">
    <svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="5"/><line x1="12" y1="1" x2="12" y2="3"/><line x1="12" y1="21" x2="12" y2="23"/><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/><line x1="1" y1="12" x2="3" y2="12"/><line x1="21" y1="12" x2="23" y2="12"/><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/></svg>
  </span>
</button>

Slide

<button class="sui-swap sui-swap-slide">
  <span class="sui-swap-on">
    <svg viewBox="0 0 24 24"><path d="M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z"/></svg>
  </span>
  <span class="sui-swap-off">
    <svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="5"/><line x1="12" y1="1" x2="12" y2="3"/><line x1="12" y1="21" x2="12" y2="23"/><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/><line x1="1" y1="12" x2="3" y2="12"/><line x1="21" y1="12" x2="23" y2="12"/><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/></svg>
  </span>
</button>

Cycle

Sort
Repeat
Align
Traffic Light
<!-- Sort: 3 states (none → ascending → descending) -->
<button class="sui-swap sui-swap-cycle sui-swap-rotate">
  <span class="sui-swap-state active">
    <svg viewBox="0 0 24 24"><line x1="8" y1="6" x2="21" y2="6"/><line x1="8" y1="12" x2="21" y2="12"/><line x1="8" y1="18" x2="21" y2="18"/><line x1="3" y1="6" x2="3.01" y2="6"/><line x1="3" y1="12" x2="3.01" y2="12"/><line x1="3" y1="18" x2="3.01" y2="18"/></svg>
  </span>
  <span class="sui-swap-state">
    <svg viewBox="0 0 24 24"><line x1="12" y1="19" x2="12" y2="5"/><polyline points="5 12 12 5 19 12"/></svg>
  </span>
  <span class="sui-swap-state">
    <svg viewBox="0 0 24 24"><line x1="12" y1="5" x2="12" y2="19"/><polyline points="19 12 12 19 5 12"/></svg>
  </span>
</button>

<!-- Repeat: off → all → one -->
<button class="sui-swap sui-swap-cycle sui-swap-fade">
  <span class="sui-swap-state active">
    <svg viewBox="0 0 24 24"><polyline points="17 1 21 5 17 9"/><path d="M3 11V9a4 4 0 014-4h14"/><polyline points="7 23 3 19 7 15"/><path d="M21 13v2a4 4 0 01-4 4H3"/></svg>
  </span>
  <span class="sui-swap-state">
    <svg viewBox="0 0 24 24" style="stroke:var(--sui-primary);"><polyline points="17 1 21 5 17 9"/><path d="M3 11V9a4 4 0 014-4h14"/><polyline points="7 23 3 19 7 15"/><path d="M21 13v2a4 4 0 01-4 4H3"/></svg>
  </span>
  <span class="sui-swap-state">
    <svg viewBox="0 0 24 24" style="stroke:var(--sui-success);"><polyline points="17 1 21 5 17 9"/><path d="M3 11V9a4 4 0 014-4h14"/><polyline points="7 23 3 19 7 15"/><path d="M21 13v2a4 4 0 01-4 4H3"/><text x="12" y="15" text-anchor="middle" font-size="8" font-weight="700" fill="currentColor" stroke="none">1</text></svg>
  </span>
</button>

<!-- Align: left → center → right -->
<button class="sui-swap sui-swap-cycle sui-swap-slide-x">
  <span class="sui-swap-state active">
    <svg viewBox="0 0 24 24"><line x1="17" y1="10" x2="3" y2="10"/><line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="14" x2="3" y2="14"/><line x1="17" y1="18" x2="3" y2="18"/></svg>
  </span>
  <span class="sui-swap-state">
    <svg viewBox="0 0 24 24"><line x1="18" y1="10" x2="6" y2="10"/><line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="14" x2="3" y2="14"/><line x1="18" y1="18" x2="6" y2="18"/></svg>
  </span>
  <span class="sui-swap-state">
    <svg viewBox="0 0 24 24"><line x1="21" y1="10" x2="7" y2="10"/><line x1="21" y1="6" x2="3" y2="6"/><line x1="21" y1="14" x2="3" y2="14"/><line x1="21" y1="18" x2="7" y2="18"/></svg>
  </span>
</button>

<!-- Traffic light: red → yellow → green -->
<button class="sui-swap sui-swap-cycle sui-swap-fade">
  <span class="sui-swap-state active">
    <svg viewBox="0 0 24 24" style="fill:var(--sui-danger);stroke:var(--sui-danger);"><circle cx="12" cy="12" r="10"/></svg>
  </span>
  <span class="sui-swap-state">
    <svg viewBox="0 0 24 24" style="fill:var(--sui-warning);stroke:var(--sui-warning);"><circle cx="12" cy="12" r="10"/></svg>
  </span>
  <span class="sui-swap-state">
    <svg viewBox="0 0 24 24" style="fill:var(--sui-success);stroke:var(--sui-success);"><circle cx="12" cy="12" r="10"/></svg>
  </span>
</button>

With Text

<button class="sui-swap sui-swap-text sui-swap-rotate">
  <span class="sui-swap-on">ON</span>
  <span class="sui-swap-off">OFF</span>
</button>

<button class="sui-swap sui-swap-text sui-swap-fade">
  <span class="sui-swap-on">Pause</span>
  <span class="sui-swap-off">Play</span>
</button>

<button class="sui-swap sui-swap-text sui-swap-slide">
  <span class="sui-swap-on">Hide</span>
  <span class="sui-swap-off">Show</span>
</button>

<button class="sui-swap sui-swap-text">
  <span class="sui-swap-on">Yes</span>
  <span class="sui-swap-off">No</span>
</button>

Raised

<button class="sui-swap sui-swap-raised sui-swap-rotate">
  <span class="sui-swap-on">
    <svg viewBox="0 0 24 24"><path d="M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z"/></svg>
  </span>
  <span class="sui-swap-off">
    <svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="5"/><line x1="12" y1="1" x2="12" y2="3"/><line x1="12" y1="21" x2="12" y2="23"/><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/><line x1="1" y1="12" x2="3" y2="12"/><line x1="21" y1="12" x2="23" y2="12"/><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/></svg>
  </span>
</button>

<button class="sui-swap sui-swap-raised sui-swap-fade">
  <span class="sui-swap-on">
    <svg viewBox="0 0 24 24" style="fill:var(--sui-danger);stroke:var(--sui-danger);"><path d="M20.84 4.61a5.5 5.5 0 00-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 00-7.78 7.78L12 21.23l8.84-8.84a5.5 5.5 0 000-7.78z"/></svg>
  </span>
  <span class="sui-swap-off">
    <svg viewBox="0 0 24 24"><path d="M20.84 4.61a5.5 5.5 0 00-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 00-7.78 7.78L12 21.23l8.84-8.84a5.5 5.5 0 000-7.78z"/></svg>
  </span>
</button>

Inset

<button class="sui-swap sui-swap-inset sui-swap-rotate">
  <span class="sui-swap-on">
    <svg viewBox="0 0 24 24"><path d="M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z"/></svg>
  </span>
  <span class="sui-swap-off">
    <svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="5"/><line x1="12" y1="1" x2="12" y2="3"/><line x1="12" y1="21" x2="12" y2="23"/><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/><line x1="1" y1="12" x2="3" y2="12"/><line x1="21" y1="12" x2="23" y2="12"/><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/></svg>
  </span>
</button>

<button class="sui-swap sui-swap-inset sui-swap-flip">
  <span class="sui-swap-on">
    <svg viewBox="0 0 24 24" style="fill:var(--sui-danger);stroke:var(--sui-danger);"><path d="M20.84 4.61a5.5 5.5 0 00-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 00-7.78 7.78L12 21.23l8.84-8.84a5.5 5.5 0 000-7.78z"/></svg>
  </span>
  <span class="sui-swap-off">
    <svg viewBox="0 0 24 24"><path d="M20.84 4.61a5.5 5.5 0 00-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 00-7.78 7.78L12 21.23l8.84-8.84a5.5 5.5 0 000-7.78z"/></svg>
  </span>
</button>

<button class="sui-swap sui-swap-inset sui-swap-text sui-swap-fade">
  <span class="sui-swap-on">ON</span>
  <span class="sui-swap-off">OFF</span>
</button>

Delete this item?

This action cannot be undone. This will permanently delete the item and remove all associated data.