All effectsLoading & feedback

Parallel Transfer Queue

并行传输队列

Multiple transfers progress independently and can be paused or resumed without resetting their peers.

Start the two sample transfers and pause either one

Where to use it

Keep per-file progress understandable when handling a batch of media or documents. Keep pause and resume on each file row when some items can finish while others are waiting.

Practical example

A field reporter transfers a video and two photos. Pausing the video leaves its progress where it was, while the photos continue and can finish independently.

AI prompt

Build a transfer queue for [files]. Key items by ID, maintain progress and state per item, make pause/resume independent, and use a separate aggregate status that updates only on meaningful changes.

Example code

Save the standalone HTML as a file and open it in your browser. It uses the same code as the preview.

View HTML
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Parallel Transfer Queue</title>
  <style>
    :root {
      color-scheme: dark;
      --demo-bg: #171629;
      --demo-ink: #f8f5ff;
      --demo-accent: #b9a6ff;
      --demo-muted: #bfbbd3;
      font-family: system-ui, sans-serif;
      color: var(--demo-ink);
      background: var(--demo-bg);
    }

    *, *::before, *::after { box-sizing: border-box; }
    body { margin: 0; min-width: 0; }
    button, input { font: inherit; }

    .demo {
      display: grid;
      place-items: center;
      align-content: center;
      min-height: 100vh;
      padding: 14px;
      overflow: hidden;
      background: radial-gradient(ellipse at 50% 24%, #28233f, var(--demo-bg) 78%);
    }

    .demo-button {
      border: 1px solid #ffffff3d;
      border-radius: 7px;
      background: #ffffff12;
      color: var(--demo-ink);
      padding: 6px 11px;
      font-size: 12px;
      cursor: pointer;
    }

    :focus-visible {
      outline: 2px solid var(--demo-accent);
      outline-offset: 3px;
    }

    .ui { width: min(100%, 238px); display: grid; gap: 8px; position: relative; font-size: 12px; line-height: 1.35; }
    .ui .surface { min-width: 0; border: 1px solid #676591; border-radius: 10px; background: #282744; padding: 8px; }
    .ui .bar { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
    .ui .actions { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 5px; }
    .ui .muted { color: #cecae9; font-size: 11px; }
    .ui .center { text-align: center; }
    .ui .mono { font: 11px ui-monospace, monospace; font-variant-numeric: tabular-nums; }
    .ui p { margin: 0; }
    .ui .button { min-height: 30px; padding: 4px 7px; border-radius: 7px; border: 1px solid #79779f; background: #3d3a60; color: #f9f5ff; font-size: 11px; font-weight: 650; cursor: pointer; }
    .ui .button:hover { background: #4e4976; }
    .ui .primary { background: #c5eeec; border-color: #dafaee; color: #17213b; }
    .ui .primary:hover { background: #e3fff9; }
    .ui .button:disabled { opacity: .6; cursor: default; }
    .ui .field { min-width: 0; width: 100%; border: 1px solid #79779f; border-radius: 6px; background: #1b1a31; color: #faf5ff; padding: 5px 7px; font-size: 12px; }
    .ui .field::placeholder { color: #c2bcdd; }
    .ui input[type="range"] { accent-color: #b8ebe0; width: 100%; min-width: 0; margin: 0; }
    .ui button { font: inherit; }
    .ui [hidden] { display: none !important; }
    .ui progress { accent-color: #b8ebe0; }
    @media (prefers-reduced-motion: reduce) {
      .ui *, .ui *::after, .ui *::before { transition-duration: 0s !important; animation-duration: 0s !important; scroll-behavior: auto !important; }
    }
    .queue{display:grid;gap:5px}.transfer{display:grid;grid-template-columns:1fr 28px;gap:8px;align-items:center}.transfer label{display:grid;gap:2px;font-size:11px}.transfer progress{height:7px;width:100%}.ui .pause{padding:0;min-height:27px}.transfer[data-state=paused] progress{opacity:.5}
  </style>
</head>
<body>
  <main class="demo">
    <div class="ui"><div class="surface queue"><div class="transfer" data-speed="7"><label><span>landscape.png</span><progress value="0" max="100"></progress></label><button class="button pause" type="button" disabled aria-label="Pause landscape.png">Ⅱ</button></div><div class="transfer" data-speed="4"><label><span>field-notes.pdf</span><progress value="0" max="100"></progress></label><button class="button pause" type="button" disabled aria-label="Pause field-notes.pdf">Ⅱ</button></div></div><div class="bar"><span class="muted" role="status">0 of 2 complete</span><button class="button primary start" type="button">Start queue</button></div></div>
  </main>
  <script>
    const jobs = [...document.querySelectorAll('.transfer')].map((row) => ({ row, progress: row.querySelector('progress'), button: row.querySelector('button'), state: 'waiting', speed: Number(row.dataset.speed) }));
    const start = document.querySelector('.start');
    const status = document.querySelector('[role=status]');
    let timer = 0;
    function summarize() { const count = jobs.filter((job) => job.state === 'done').length; status.textContent = "Complete " + count + ' / 2'; }
    function set(job, state) { job.state = state; job.row.dataset.state = state; job.button.disabled = state === 'done'; job.button.textContent = state === 'done' ? '✓' : state === 'paused' ? '▶' : 'Ⅱ'; const name = job.row.querySelector('span').textContent; job.button.setAttribute('aria-label', (state === 'done' ? "Completed" : state === 'paused' ? "Resume" : "Pause") + ' ' + name); }
    for (const job of jobs) job.button.addEventListener('click', () => set(job, job.state === 'paused' ? 'active' : 'paused'));
    start.addEventListener('click', () => {
      start.disabled = true;
      for (const job of jobs) { job.progress.value = 0; set(job, 'active'); }
      summarize();
      timer = setInterval(() => {
        for (const job of jobs) if (job.state === 'active') { job.progress.value = Math.min(100, job.progress.value + job.speed); if (job.progress.value === 100) { set(job, 'done'); summarize(); } }
        if (jobs.every((job) => job.state === 'done')) { clearInterval(timer); start.disabled = false; }
      }, 75);
    });
  </script>
</body>
</html>

Original example by UI Skills

Further examples