#117 ui light mobile: native-first Gestures & Triage

Inline Swipe-to-Reveal Row Actions

Inbox rows that reveal color-coded Archive, Pin, Snooze, and Delete trays on horizontal swipe, with desktop hover parity.

Inspired by Spark Mail ↗

Download .html
Fullscreen ↗

WHY THIS AESTHETIC IS UNIQUE

Keeps list rows clean and scannable while placing high-frequency triage actions directly beneath each row for effortless thumb swipes.

BEST FOR

Email & notification inboxesTask & reminder listsSupport ticket queuesBanking & transaction feeds

TAGS

COLOR PALETTE (CLICK TO COPY HEX)

TYPOGRAPHY

Display
Plus Jakarta Sans
Body
Inter
Mono
JetBrains Mono
Scale
Bold unread sender lines (15px), single-line truncated subjects, and crisp 12px timestamps.

Google Fonts Stylesheet ↗

ARCHITECTURE & MOBILE NOTES

LAYOUT

Clean message list with filter tabs (Inbox, Pinned, Snoozed, Archived), layered swipeable rows, and a bottom Undo snackbar.

INTERACTION

Dragging a row right reveals emerald Archive / amber Pin actions; dragging left reveals indigo Snooze / rose Delete actions, snapping open at threshold or triggering on full swipe, with hover action buttons on desktop.

MOBILE

Locks horizontal drag only after clear horizontal intent (dx > dy) so vertical scrolling stays silky smooth.

AI AGENT GUARDRAILS

DO

  • Always expose equivalent hover/focus action buttons on desktop so mouse and keyboard users never need to drag
  • Use distinct semantic colors and icons for left vs. right swipe trays (e.g., green Archive vs. red Delete)
  • Provide an immediate Undo snackbar for every swipe-triggered archive, snooze, or delete

DON'T

  • Do not allow multiple rows to remain swiped open simultaneously; close the previous row when starting a new swipe
  • Do not trigger destructive deletes on tiny accidental horizontal nudges
STANDALONE SOURCE · demos/inline-swipe-row-actions.html (18.2 KB)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Mailstream — Inline Swipe Row Actions</title>
<style>
  :root {
    --canvas: #F6F8FB;
    --surface: #FFFFFF;
    --ink: #111827;
    --accent: #2563EB;
    --muted: #64748B;
    --border: #E2E8F0;
    --emerald: #059669;
    --amber: #D97706;
    --indigo: #4F46E5;
    --rose: #E11D48;
    --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
  }

  * { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

  body {
    background: var(--canvas);
    color: var(--ink);
    font-family: var(--font);
    min-height: 100dvh;
    overflow-x: hidden;
  }

  .app {
    max-width: 840px;
    margin: 0 auto;
    padding: 18px 14px 96px;
  }

  @media (min-width: 720px) {
    .app { padding: 32px 24px 96px; }
  }

  .topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
  }

  .topbar h1 {
    font-size: 24px;
    font-weight: 750;
    letter-spacing: -0.02em;
  }

  .topbar p {
    font-size: 13px;
    color: var(--muted);
    margin-top: 2px;
  }

  .restore-btn {
    min-height: 44px;
    padding: 0 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--ink);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
  }
  .restore-btn:hover { border-color: var(--accent); color: var(--accent); }

  /* Filter tabs */
  .tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    margin-bottom: 14px;
  }
  .tabs::-webkit-scrollbar { display: none; }

  .tab-btn {
    min-height: 44px;
    padding: 0 14px;
    border-radius: 11px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
  }

  .tab-btn[aria-selected="true"] {
    background: var(--surface);
    color: var(--ink);
    border-color: var(--border);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.05);
  }

  .tab-count {
    font-size: 11px;
    padding: 1px 7px;
    border-radius: 999px;
    background: #EFF6FF;
    color: var(--accent);
  }

  /* Gesture legend */
  .gesture-hint {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    padding: 0 4px 8px;
    flex-wrap: wrap;
  }
  .gesture-hint .r { color: var(--emerald); }
  .gesture-hint .l { color: var(--rose); }

  /* Inbox container */
  .inbox-list {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.04);
  }

  .swipe-row {
    position: relative;
    overflow: hidden;
    border-bottom: 1px solid var(--border);
    user-select: none;
    -webkit-user-select: none;
  }
  .swipe-row:last-child { border-bottom: none; }

  /* Revealed action trays underneath */
  .tray {
    position: absolute;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: stretch;
  }
  .tray-left { left: 0; }
  .tray-right { right: 0; }

  .tray-btn {
    min-width: 78px;
    border: none;
    color: #fff;
    font-family: var(--font);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 0 10px;
  }
  .tray-btn.archive { background: var(--emerald); }
  .tray-btn.pin { background: var(--amber); }
  .tray-btn.snooze { background: var(--indigo); }
  .tray-btn.delete { background: var(--rose); }

  /* Draggable Foreground Row */
  .row-fg {
    position: relative;
    z-index: 2;
    background: var(--surface);
    padding: 13px 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    touch-action: pan-y;
    cursor: grab;
    transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), background 0.15s;
  }
  .row-fg.dragging { transition: none; cursor: grabbing; }
  .row-fg:hover { background: #FAFBFD; }

  .avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    font-size: 13px;
    font-weight: 750;
    color: #fff;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    margin-top: 2px;
  }

  .msg-body {
    flex: 1;
    min-width: 0;
  }

  .msg-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
  }

  .sender {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .unread-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
  }

  .pin-badge {
    font-size: 11px;
    color: var(--amber);
    font-weight: 700;
  }

  .time {
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
    flex-shrink: 0;
  }

  .subject {
    font-size: 14px;
    color: var(--ink);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .swipe-row.unread .subject { font-weight: 700; }

  .snippet {
    font-size: 13px;
    color: var(--muted);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Desktop hover quick actions */
  .hover-actions {
    display: none;
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    gap: 4px;
    background: #FAFBFD;
    padding: 4px;
    border-radius: 10px;
    border: 1px solid var(--border);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
  }

  @media (hover: hover) and (min-width: 720px) {
    .row-fg:hover .hover-actions { display: flex; }
  }

  .quick-act {
    min-width: 36px;
    min-height: 36px;
    padding: 0 9px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
  }
  .quick-act:hover { background: #EEF2F6; color: var(--ink); }
  .quick-act.del:hover { background: #FFF1F2; color: var(--rose); }
  .quick-act.arc:hover { background: #ECFDF5; color: var(--emerald); }

  .empty-inbox {
    padding: 48px 20px;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
  }

  /* Undo Snackbar */
  .snackbar {
    position: fixed;
    left: 50%;
    bottom: 20px;
    transform: translate(-50%, 90px);
    background: #111827;
    color: #fff;
    padding: 10px 12px 10px 16px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 14px 32px rgba(15, 23, 42, 0.32);
    z-index: 50;
    transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
    max-width: calc(100% - 28px);
  }
  .snackbar.show { transform: translate(-50%, 0); }

  .undo-btn {
    min-height: 36px;
    padding: 0 12px;
    border: none;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
  }
</style>
</head>
<body>
  <div class="app">
    <header class="topbar">
      <div>
        <h1>Inbox</h1>
        <p>Swipe rows right to Archive/Pin, or left to Snooze/Delete</p>
      </div>
      <button class="restore-btn" id="resetBtn">Reset Demo</button>
    </header>

    <nav class="tabs" role="tablist" aria-label="Mailbox folders">
      <button class="tab-btn" role="tab" data-tab="inbox" aria-selected="true">Inbox <span class="tab-count" id="cInbox">0</span></button>
      <button class="tab-btn" role="tab" data-tab="pinned" aria-selected="false">Pinned <span class="tab-count" id="cPinned">0</span></button>
      <button class="tab-btn" role="tab" data-tab="snoozed" aria-selected="false">Snoozed <span class="tab-count" id="cSnoozed">0</span></button>
      <button class="tab-btn" role="tab" data-tab="archived" aria-selected="false">Archived <span class="tab-count" id="cArchived">0</span></button>
    </nav>

    <div class="gesture-hint">
      <span class="r">→ Drag right: Archive · Pin</span>
      <span class="l">← Drag left: Snooze · Delete</span>
    </div>

    <main class="inbox-list" id="inboxList"></main>
  </div>

  <div class="snackbar" id="snackbar" role="status" aria-live="polite">
    <span id="snackText">Archived conversation</span>
    <button class="undo-btn" id="undoBtn">Undo</button>
  </div>

<script>
(() => {
  const INITIAL_MAIL = [
    { id: 1, sender: 'Maya Lin-Sato', initials: 'ML', color: '#2563EB', time: '9:42 AM', subject: 'Updated typography tokens for v3.2 release', snippet: 'Pushed the final optical scale adjustments to Figma — ready for engineering sign-off before noon.', unread: true, pinned: true, status: 'inbox' },
    { id: 2, sender: 'Fastmail Security', initials: 'FS', color: '#059669', time: '9:15 AM', subject: 'New passkey enrolled on MacBook Pro', snippet: 'A hardware-backed WebAuthn passkey was added to your account from Seattle, WA.', unread: true, pinned: false, status: 'inbox' },
    { id: 3, sender: 'Devon Morales', initials: 'DM', color: '#7C3AED', time: '8:50 AM', subject: 'Re: Friday architecture review agenda', snippet: 'Let us trim the migration slide deck to 10 minutes so we have room for Q&A on cache invalidation.', unread: false, pinned: false, status: 'inbox' },
    { id: 4, sender: 'Linear Digest', initials: 'LD', color: '#4F46E5', time: 'Yesterday', subject: '4 issues moved to In Review in Mobile Core', snippet: 'Swipe physics polish, keyboard shortcut conflict fix, and offline queue retry backoff.', unread: false, pinned: false, status: 'inbox' },
    { id: 5, sender: 'Claire Beaumont', initials: 'CB', color: '#D97706', time: 'Yesterday', subject: 'Invoice #4092 — Studio Sound Mixing', snippet: 'Attached is the final PDF invoice for the launch video mastering session. Net-30 terms apply.', unread: true, pinned: false, status: 'inbox' },
    { id: 6, sender: 'Kenji Watanabe', initials: 'KW', color: '#0891B2', time: 'Mon', subject: 'Coffee near Pioneer Square next week?', snippet: 'In town Tuesday through Thursday for the design systems summit—would love to catch up.', unread: false, pinned: false, status: 'inbox' },
    { id: 7, sender: 'Stripe Billing', initials: 'SB', color: '#334155', time: 'Sun', subject: 'Your monthly cloud infrastructure receipt', snippet: 'Payment of $148.00 succeeded for workspace billing period ending this Sunday.', unread: false, pinned: false, status: 'archived' }
  ];

  let messages = structuredClone(INITIAL_MAIL);
  let activeTab = 'inbox';
  let lastUndo = null;
  let openRowReset = null;
  let snackTimer = null;

  const listEl = document.getElementById('inboxList');
  const snackbar = document.getElementById('snackbar');
  const snackText = document.getElementById('snackText');

  function showUndo(label, undoFn) {
    lastUndo = undoFn;
    snackText.textContent = label;
    snackbar.classList.add('show');
    clearTimeout(snackTimer);
    snackTimer = setTimeout(() => snackbar.classList.remove('show'), 4500);
  }

  function applyAction(id, action) {
    const msg = messages.find(m => m.id === id);
    if (!msg) return;
    const prev = { status: msg.status, pinned: msg.pinned };

    if (action === 'archive') {
      msg.status = msg.status === 'archived' ? 'inbox' : 'archived';
      showUndo(msg.status === 'archived' ? `Archived "${msg.sender}"` : `Moved "${msg.sender}" to Inbox`, () => {
        Object.assign(msg, prev); render();
      });
    } else if (action === 'pin') {
      msg.pinned = !msg.pinned;
      showUndo(msg.pinned ? `Pinned "${msg.sender}"` : `Unpinned "${msg.sender}"`, () => {
        Object.assign(msg, prev); render();
      });
    } else if (action === 'snooze') {
      msg.status = 'snoozed';
      showUndo(`Snoozed "${msg.sender}" until tomorrow 9:00 AM`, () => {
        Object.assign(msg, prev); render();
      });
    } else if (action === 'delete') {
      const idx = messages.findIndex(m => m.id === id);
      const removed = messages.splice(idx, 1)[0];
      showUndo(`Deleted "${removed.sender}"`, () => {
        messages.splice(idx, 0, removed); render();
      });
    }
    render();
  }

  function attachSwipe(rowEl, fgEl, msgId) {
    let startX = 0, startY = 0, baseOffset = 0, currentX = 0;
    let mode = null; // 'h' or 'v'
    const SNAP_WIDTH = 156;
    const FULL_COMMIT = 205;

    const setX = (x, animate) => {
      fgEl.classList.toggle('dragging', !animate);
      fgEl.style.transform = `translate3d(${x}px, 0, 0)`;
      currentX = x;
    };

    const closeSelf = () => setX(0, true);

    fgEl.addEventListener('pointerdown', e => {
      if (e.target.closest('button')) return;
      if (openRowReset && openRowReset !== closeSelf) {
        openRowReset();
        openRowReset = null;
      }
      startX = e.clientX;
      startY = e.clientY;
      baseOffset = currentX;
      mode = null;
      fgEl.setPointerCapture(e.pointerId);
    });

    fgEl.addEventListener('pointermove', e => {
      if (!fgEl.hasPointerCapture(e.pointerId)) return;
      const dx = e.clientX - startX;
      const dy = e.clientY - startY;

      if (!mode) {
        if (Math.abs(dx) > 8 && Math.abs(dx) > Math.abs(dy)) mode = 'h';
        else if (Math.abs(dy) > 8) { mode = 'v'; return; }
        else return;
      }
      if (mode !== 'h') return;

      let next = baseOffset + dx;
      // Soft resistance past SNAP_WIDTH
      if (next > SNAP_WIDTH) next = SNAP_WIDTH + (next - SNAP_WIDTH) * 0.45;
      if (next < -SNAP_WIDTH) next = -SNAP_WIDTH + (next + SNAP_WIDTH) * 0.45;
      setX(next, false);
    });

    const endDrag = () => {
      if (mode !== 'h') return;
      mode = null;

      if (currentX >= FULL_COMMIT) {
        setX(360, true);
        setTimeout(() => applyAction(msgId, 'archive'), 140);
      } else if (currentX <= -FULL_COMMIT) {
        setX(-360, true);
        setTimeout(() => applyAction(msgId, 'delete'), 140);
      } else if (currentX >= 68) {
        setX(SNAP_WIDTH, true);
        openRowReset = closeSelf;
      } else if (currentX <= -68) {
        setX(-SNAP_WIDTH, true);
        openRowReset = closeSelf;
      } else {
        closeSelf();
      }
    };

    fgEl.addEventListener('pointerup', endDrag);
    fgEl.addEventListener('pointercancel', endDrag);
  }

  function render() {
    document.getElementById('cInbox').textContent = messages.filter(m => m.status === 'inbox').length;
    document.getElementById('cPinned').textContent = messages.filter(m => m.pinned && m.status !== 'archived').length;
    document.getElementById('cSnoozed').textContent = messages.filter(m => m.status === 'snoozed').length;
    document.getElementById('cArchived').textContent = messages.filter(m => m.status === 'archived').length;

    const visible = messages.filter(m => {
      if (activeTab === 'inbox') return m.status === 'inbox';
      if (activeTab === 'pinned') return m.pinned && m.status !== 'archived';
      if (activeTab === 'snoozed') return m.status === 'snoozed';
      if (activeTab === 'archived') return m.status === 'archived';
      return true;
    });

    listEl.innerHTML = '';
    if (visible.length === 0) {
      listEl.innerHTML = `<div class="empty-inbox">All clear in <strong>${activeTab}</strong>.</div>`;
      return;
    }

    visible.forEach(msg => {
      const row = document.createElement('div');
      row.className = `swipe-row${msg.unread ? ' unread' : ''}`;
      row.innerHTML = `
        <div class="tray tray-left">
          <button class="tray-btn archive" data-act="archive">${msg.status === 'archived' ? 'Inbox' : 'Archive'}</button>
          <button class="tray-btn pin" data-act="pin">${msg.pinned ? 'Unpin' : 'Pin'}</button>
        </div>
        <div class="tray tray-right">
          <button class="tray-btn snooze" data-act="snooze">Snooze</button>
          <button class="tray-btn delete" data-act="delete">Delete</button>
        </div>
        <div class="row-fg">
          <div class="avatar" style="background:${msg.color}">${msg.initials}</div>
          <div class="msg-body">
            <div class="msg-top">
              <span class="sender">
                ${msg.unread ? '<span class="unread-dot" aria-label="Unread"></span>' : ''}
                ${msg.sender}
                ${msg.pinned ? '<span class="pin-badge">★</span>' : ''}
              </span>
              <span class="time">${msg.time}</span>
            </div>
            <div class="subject">${msg.subject}</div>
            <div class="snippet">${msg.snippet}</div>
          </div>
          <div class="hover-actions">
            <button class="quick-act arc" data-act="archive">${msg.status === 'archived' ? 'Inbox' : 'Archive'}</button>
            <button class="quick-act" data-act="pin">${msg.pinned ? 'Unpin' : 'Pin'}</button>
            <button class="quick-act" data-act="snooze">Snooze</button>
            <button class="quick-act del" data-act="delete">Delete</button>
          </div>
        </div>
      `;

      row.querySelectorAll('[data-act]').forEach(btn => {
        btn.addEventListener('click', e => {
          e.stopPropagation();
          applyAction(msg.id, btn.dataset.act);
        });
      });

      const fg = row.querySelector('.row-fg');
      fg.addEventListener('click', () => {
        if (msg.unread) { msg.unread = false; render(); }
      });

      attachSwipe(row, fg, msg.id);
      listEl.appendChild(row);
    });
  }

  document.querySelectorAll('.tab-btn').forEach(btn => {
    btn.addEventListener('click', () => {
      document.querySelectorAll('.tab-btn').forEach(b => b.setAttribute('aria-selected', 'false'));
      btn.setAttribute('aria-selected', 'true');
      activeTab = btn.dataset.tab;
      render();
    });
  });

  document.getElementById('undoBtn').addEventListener('click', () => {
    if (lastUndo) {
      lastUndo();
      lastUndo = null;
      snackbar.classList.remove('show');
    }
  });

  document.getElementById('resetBtn').addEventListener('click', () => {
    messages = structuredClone(INITIAL_MAIL);
    activeTab = 'inbox';
    document.querySelectorAll('.tab-btn').forEach(b => b.setAttribute('aria-selected', String(b.dataset.tab === 'inbox')));
    snackbar.classList.remove('show');
    render();
  });

  render();
})();
</script>
</body>
</html>