Skip to content

List Reorder

A copy-paste view transitions component in pure HTML, CSS & vanilla JS. Zero dependencies, framework-agnostic, MIT-licensed.

View TransitionsHTMLCSSJavaScriptany framework
  • Alpha
  • Bravo
  • Charlie

Copy into your project

HTML
<div class="nuda-vt-reorder">
  <ul class="nuda-vt-reorder__list">
    <li class="nuda-vt-reorder__item" style="view-transition-name:vt-reorder-alpha">Alpha</li>
    <li class="nuda-vt-reorder__item" style="view-transition-name:vt-reorder-bravo">Bravo</li>
    <li class="nuda-vt-reorder__item" style="view-transition-name:vt-reorder-charlie">Charlie</li>
  </ul>
  <button type="button" class="nuda-vt-reorder__btn">Shuffle</button>
</div>
CSS
/* List Reorder
   Each item gets a unique view-transition-name, so when the DOM order changes
   the API animates every item from its old slot to its new one (FLIP for free).
   Customize: per-item names, group animation timing */

.nuda-vt-reorder__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 200px;
}

.nuda-vt-reorder__item {
  --vt-accent: #e4ff54;
  background: #18181b;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-left: 3px solid var(--vt-accent);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-weight: 700;
  color: #fff;
}

/* Give each item its own stable name (set inline or generate per id). */
.nuda-vt-reorder__item:nth-child(1) { view-transition-name: vt-reorder-alpha; }
.nuda-vt-reorder__item:nth-child(2) { view-transition-name: vt-reorder-bravo; }
.nuda-vt-reorder__item:nth-child(3) { view-transition-name: vt-reorder-charlie; }

.nuda-vt-reorder__btn {
  background: #e4ff54;
  color: #09090b;
  border: none;
  border-radius: 8px;
  padding: 0.5rem 1rem;
  font-weight: 700;
  cursor: pointer;
}

.nuda-vt-reorder__btn:focus-visible {
  outline: 2px solid #e4ff54;
  outline-offset: 2px;
}

/* Animate every named group as it shifts position. */
::view-transition-group(*) {
  animation-duration: 0.45s;
  animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*) { animation: none; }
}
JavaScript
/* List Reorder — vanilla JS
   Rotates the list (moves the first item to the end) in a view transition. */

(function () {
  document.querySelectorAll(".nuda-vt-reorder").forEach(function (root) {
    var list = root.querySelector(".nuda-vt-reorder__list");
    var btn = root.querySelector(".nuda-vt-reorder__btn");

    function doSwap() {
      if (list.firstElementChild) list.appendChild(list.firstElementChild);
    }

    btn.addEventListener("click", function () {
      if (!document.startViewTransition) { doSwap(); return; }
      document.startViewTransition(doSwap);
    });
  });
})();

How to use List Reorder

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 view transitions components

← Browse all NudaUI components