# #124 — Adaptive Bottom-Tab + Contextual Sub-Nav Bar

> Persistent 5-tab mobile bottom bar (left rail on desktop) paired with a contextual pill sub-nav that morphs per tab.

## Metadata

- **Index**: #124
- **Slug**: `adaptive-bottom-tab-subnav`
- **Kind**: `ui`
- **Family**: Navigation & Docks
- **Theme**: `light`
- **Mobile Strength**: `native-first`
- **Tags**: `bottom-tabs`, `contextual-subnav`, `adaptive-nav`, `fintech-app`, `responsive-shell`
- **Best For**: Mobile banking & fintech apps, Social & community platforms, Health & fitness dashboards, Multi-module SaaS apps
- **Real-World Inspiration**: [Monzo](https://monzo.com)
- **Detail Page**: https://templates.michaelpitts.net/t/adaptive-bottom-tab-subnav
- **Live Demo**: https://templates.michaelpitts.net/demos/adaptive-bottom-tab-subnav.html
- **JSON API**: https://templates.michaelpitts.net/api/templates/adaptive-bottom-tab-subnav

## Why This Aesthetic Is Unique

Organizes complex multi-section apps cleanly by separating global destination switching from per-section sub-views without ever resorting to nested hamburger drawers.

## Color Palette

| Role | Name | Hex |
|------|------|-----|
| `canvas` | Cloud Ledger | `#F4F6F9` |
| `surface` | Card White | `#FFFFFF` |
| `ink` | Deep Navy | `#14233C` |
| `accent` | Hot Coral | `#FF4D57` |
| `muted` | Harbor Slate | `#62728A` |

## Typography

- **Display**: `Plus Jakarta Sans`
- **Body**: `Inter`
- **Mono**: `JetBrains Mono`
- **Scale Notes**: Crisp 11px bottom-tab labels, 13px contextual pill tabs, and tabular-nums monetary balances.
- **Google Fonts**: https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800&family=JetBrains+Mono:wght@600&family=Plus+Jakarta+Sans:wght@700;800&display=swap
  ```html
  <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800&family=JetBrains+Mono:wght@600&family=Plus+Jakarta+Sans:wght@700;800&display=swap">
  ```

## Layout Architecture

Fixed 5-column bottom tab bar on mobile that transforms into a sticky 230px left navigation rail at >=900px, paired with a sticky top contextual pill sub-nav.

## Interaction & Micro-Motion Rules

Switching any primary tab dynamically swaps the contextual sub-nav pills and hero/list view with zero page reload, preserving clear active states in both navigation tiers.

## Mobile & Responsive Rules

50px-tall bottom tabs with safe-area-inset-bottom support and horizontally scrollable contextual pills prevent crowding on 390px viewports.

## Agent Guardrails

### DO
- Keep primary bottom navigation strictly to 3-5 top-level destinations with icon + short label
- Transform the bottom tab bar into a left sidebar rail on desktop screens instead of stretching a bottom bar across 1280px
- Clearly distinguish the active primary tab and active contextual sub-pill with distinct visual hierarchy

### DON'T
- Do not place 2 stacked bottom bars on mobile; keep primary tabs at the bottom and contextual sub-nav at the top
- Do not omit text labels on primary navigation tabs

## Complete Standalone Starter Code

File: `demos/adaptive-bottom-tab-subnav.html`

```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Adaptive Bottom-Tab + Contextual Sub-Nav Bar</title>
<style>
  :root {
    --canvas: #F4F6F9;
    --surface: #FFFFFF;
    --ink: #14233C;
    --accent: #FF4D57;
    --accent-soft: rgba(255, 77, 87, 0.12);
    --muted: #62728A;
    --border: #E2E7F0;
    --radius: 16px;
  }
  * { box-sizing: border-box; margin: 0; padding: 0; }
  html, body {
    min-height: 100%;
    background: var(--canvas);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
  }
  .app-frame {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
  }
  @media (min-width: 900px) {
    .app-frame {
      flex-direction: row;
    }
  }

  /* Adaptive Primary Nav: Bottom Tab Bar on Mobile, Left Rail on Desktop */
  nav.primary-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
    gap: 4px;
  }
  @media (min-width: 900px) {
    nav.primary-nav {
      position: sticky;
      top: 0;
      height: 100dvh;
      width: 230px;
      flex-shrink: 0;
      border-top: none;
      border-right: 1px solid var(--border);
      display: flex;
      flex-direction: column;
      padding: 22px 14px;
      gap: 6px;
    }
  }
  .rail-brand {
    display: none;
  }
  @media (min-width: 900px) {
    .rail-brand {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 4px 10px 20px;
      font-weight: 800;
      font-size: 1.05rem;
      letter-spacing: -0.02em;
    }
  }
  .coral-mark {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 900;
    font-size: 0.9rem;
  }

  .tab-btn {
    min-height: 50px;
    border: none;
    background: transparent;
    color: var(--muted);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 0.68rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.16s, color 0.16s;
  }
  @media (min-width: 900px) {
    .tab-btn {
      flex-direction: row;
      justify-content: flex-start;
      padding: 0 14px;
      gap: 12px;
      font-size: 0.9rem;
      min-height: 46px;
    }
  }
  .tab-btn:hover { background: var(--canvas); color: var(--ink); }
  .tab-btn.active {
    color: var(--accent);
    background: var(--accent-soft);
  }
  .tab-btn svg { width: 20px; height: 20px; flex-shrink: 0; }

  /* Main content column */
  .main-col {
    flex: 1;
    min-width: 0;
    padding-bottom: 90px;
  }
  @media (min-width: 900px) {
    .main-col { padding-bottom: 40px; }
  }

  .top-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 16px 20px 12px;
    position: sticky;
    top: 0;
    z-index: 20;
  }
  .header-row {
    max-width: 920px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }
  .header-row h1 {
    font-size: clamp(1.2rem, 3vw, 1.5rem);
    letter-spacing: -0.02em;
  }
  .balance-pill {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-weight: 700;
    font-size: 0.88rem;
    padding: 6px 12px;
    border-radius: 999px;
    background: #14233C;
    color: #fff;
  }

  /* Contextual Sub-Nav Pill Bar (morphs per active tab) */
  .subnav-rail {
    max-width: 920px;
    margin: 12px auto 0;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .subnav-rail::-webkit-scrollbar { display: none; }
  .sub-pill {
    min-height: 40px;
    padding: 0 15px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--canvas);
    color: var(--muted);
    font-size: 0.83rem;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.16s, color 0.16s, border-color 0.16s;
  }
  .sub-pill:hover { border-color: #BCC6D6; color: var(--ink); }
  .sub-pill.active {
    background: var(--ink);
    border-color: var(--ink);
    color: #fff;
  }

  .content-wrap {
    max-width: 920px;
    margin: 0 auto;
    padding: 20px 18px;
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  .hero-card {
    background: linear-gradient(135deg, #14233C 0%, #233B63 100%);
    color: #fff;
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
  }
  .hero-card small {
    display: block;
    font-size: 0.76rem;
    opacity: 0.78;
    text-transform: uppercase;
    letter-spacing: 0.08em;
  }
  .hero-card .metric {
    font-size: clamp(1.7rem, 4.5vw, 2.2rem);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.03em;
    margin-top: 2px;
  }
  .hero-cta {
    min-height: 44px;
    padding: 0 18px;
    border-radius: 999px;
    border: none;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    font-size: 0.86rem;
    cursor: pointer;
  }

  .list-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
  }
  .list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 15px 18px;
    border-bottom: 1px solid var(--border);
  }
  .list-item:last-child { border-bottom: none; }
  .item-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
  }
  .item-badge {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--canvas);
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 0.85rem;
    color: var(--ink);
    flex-shrink: 0;
  }
  .item-info strong { display: block; font-size: 0.92rem; }
  .item-info span { font-size: 0.78rem; color: var(--muted); }
  .item-amount {
    font-weight: 700;
    font-size: 0.94rem;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
  }
  .item-amount.pos { color: #059669; }
</style>
</head>
<body>
  <div class="app-frame">
    <nav class="primary-nav" aria-label="Primary navigation">
      <div class="rail-brand">
        <span class="coral-mark">K</span>
        <span>Koral Bank</span>
      </div>
      <button class="tab-btn active" data-tab="home" type="button">
        <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M3 10.5L12 3l9 7.5V20a1 1 0 0 1-1 1h-5v-6H9v6H4a1 1 0 0 1-1-1v-9.5z"/></svg>
        <span>Home</span>
      </button>
      <button class="tab-btn" data-tab="activity" type="button">
        <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M4 6h16M4 12h16M4 18h10"/></svg>
        <span>Activity</span>
      </button>
      <button class="tab-btn" data-tab="pots" type="button">
        <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="8"/><path d="M12 8v8M9 11h6"/></svg>
        <span>Pots</span>
      </button>
      <button class="tab-btn" data-tab="payments" type="button">
        <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M5 12h14M13 6l6 6-6 6"/></svg>
        <span>Pay</span>
      </button>
      <button class="tab-btn" data-tab="cards" type="button">
        <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="5" width="18" height="14" rx="2"/><path d="M3 10h18"/></svg>
        <span>Cards</span>
      </button>
    </nav>

    <div class="main-col">
      <header class="top-header">
        <div class="header-row">
          <h1 id="viewTitle">Home</h1>
          <div class="balance-pill">£4,820.40</div>
        </div>
        <div id="subnavRail" class="subnav-rail" role="tablist" aria-label="Contextual sub-navigation"></div>
      </header>

      <main class="content-wrap" id="contentWrap"></main>
    </div>
  </div>

<script>
(() => {
  const DATA = {
    home: {
      title: 'Home',
      subtabs: ['Overview', 'Left to Spend', 'Upcoming Bills', 'Insights'],
      views: {
        'Overview': {
          label: 'Current Account Balance', metric: '£4,820.40', cta: '+ Add Money',
          rows: [
            { icon: '☕', name: 'Monmouth Coffee Co.', sub: 'Today · 09:14 · Eating Out', amt: '-£4.60' },
            { icon: '🚇', name: 'TfL Contactless', sub: 'Today · 08:32 · Transport', amt: '-£3.40' },
            { icon: '💼', name: 'Northstar Design Ltd', sub: 'Yesterday · Salary Credit', amt: '+£3,450.00', pos: true },
            { icon: '🛒', name: 'Waitrose & Partners', sub: 'Yesterday · Groceries', amt: '-£42.15' }
          ]
        },
        'Left to Spend': {
          label: 'Safe to Spend (14 days left)', metric: '£1,140.00', cta: 'Adjust Budget',
          rows: [
            { icon: '🥗', name: 'Groceries Budget', sub: '£185 of £320 used', amt: '£135 left' },
            { icon: '🚆', name: 'Commute Budget', sub: '£64 of £110 used', amt: '£46 left' },
            { icon: '🎬', name: 'Entertainment', sub: '£48 of £120 used', amt: '£72 left' }
          ]
        },
        'Upcoming Bills': {
          label: 'Scheduled in Next 7 Days', metric: '£942.00', cta: 'Pay Early',
          rows: [
            { icon: '🏠', name: 'Hackney Flat Rent', sub: 'Due in 3 days · Direct Debit', amt: '-£890.00' },
            { icon: '⚡', name: 'Octopus Energy', sub: 'Due in 5 days · Standing Order', amt: '-£52.00' }
          ]
        },
        'Insights': {
          label: 'Monthly Savings Rate', metric: '28.4%', cta: 'Export CSV',
          rows: [
            { icon: '📉', name: 'Dining Down 14%', sub: 'Compared to last 30 days', amt: '+£68 saved', pos: true },
            { icon: '🎯', name: 'Round-Ups Active', sub: '34 transactions rounded up', amt: '+£19.40', pos: true }
          ]
        }
      }
    },
    activity: {
      title: 'Activity',
      subtabs: ['All', 'Card Spend', 'Transfers', 'Subscriptions'],
      views: {
        'All': {
          label: '30-Day Outflow', metric: '£1,642.80', cta: 'Filter Feed',
          rows: [
            { icon: '☕', name: 'Monmouth Coffee Co.', sub: 'Card · Contactless', amt: '-£4.60' },
            { icon: '📚', name: 'Daunt Books', sub: 'Card · Marylebone', amt: '-£24.99' },
            { icon: '🎵', name: 'Spotify Duo', sub: 'Subscription · Monthly', amt: '-£14.99' }
          ]
        },
        'Card Spend': {
          label: 'Tap & Chip This Week', metric: '£186.25', cta: 'Freeze Card',
          rows: [
            { icon: '🥖', name: 'E5 Bakehouse', sub: 'Apple Pay · 11:05', amt: '-£8.40' },
            { icon: '🚲', name: 'Lime Bike', sub: 'Contactless · 18:22', amt: '-£3.15' }
          ]
        },
        'Transfers': {
          label: 'Peer-to-Peer Splits', metric: '£215.00', cta: 'Split a Bill',
          rows: [
            { icon: '🍽️', name: 'Samir Patel', sub: 'Dinner split settled', amt: '+£38.50', pos: true },
            { icon: '🎟️', name: 'Hannah Brooks', sub: 'Concert tickets', amt: '-£64.00' }
          ]
        },
        'Subscriptions': {
          label: 'Recurring Monthly', metric: '£71.97', cta: 'Manage',
          rows: [
            { icon: '🎵', name: 'Spotify Duo', sub: 'Renews 14th', amt: '-£14.99' },
            { icon: '☁️', name: 'iCloud+ 2TB', sub: 'Renews 19th', amt: '-£8.99' },
            { icon: '🏋️', name: 'Bouldering Club', sub: 'Renews 1st', amt: '-£47.99' }
          ]
        }
      }
    },
    pots: {
      title: 'Savings Pots',
      subtabs: ['All Pots', 'Instant Access', 'Locked 4.8%'],
      views: {
        'All Pots': {
          label: 'Total Across 3 Pots', metric: '£7,240.00', cta: '+ Create Pot',
          rows: [
            { icon: '✈️', name: 'Kyoto Autumn Trip', sub: 'Target £2,500 · 72% funded', amt: '£1,800.00', pos: true },
            { icon: '🛡️', name: 'Emergency Buffer', sub: 'Instant Access · 4.1% AER', amt: '£4,200.00', pos: true },
            { icon: '🧾', name: 'Tax Reserve', sub: 'Locked Pot · 4.8% AER', amt: '£1,240.00', pos: true }
          ]
        },
        'Instant Access': {
          label: 'Liquid Savings (4.1% AER)', metric: '£6,000.00', cta: 'Deposit Now',
          rows: [
            { icon: '🛡️', name: 'Emergency Buffer', sub: 'Withdraw anytime', amt: '£4,200.00', pos: true },
            { icon: '✈️', name: 'Kyoto Autumn Trip', sub: 'Round-ups enabled', amt: '£1,800.00', pos: true }
          ]
        },
        'Locked 4.8%': {
          label: 'Fixed-Term Boost', metric: '£1,240.00', cta: 'View Maturity',
          rows: [
            { icon: '🧾', name: 'Tax Reserve', sub: 'Unlocks Jan 15 · +£59.52 est.', amt: '£1,240.00', pos: true }
          ]
        }
      }
    },
    payments: {
      title: 'Payments',
      subtabs: ['Pay Someone', 'Request', 'Scheduled'],
      views: {
        'Pay Someone': {
          label: 'Fastest Transfers (FPS)', metric: 'Zero Fees', cta: 'New Payee',
          rows: [
            { icon: 'SP', name: 'Samir Patel', sub: 'Last paid 2 days ago', amt: 'Send →' },
            { icon: 'HB', name: 'Hannah Brooks', sub: 'Last paid last week', amt: 'Send →' }
          ]
        },
        'Request': {
          label: 'Open Payment Links', metric: '£38.50', cta: 'Create Link',
          rows: [
            { icon: '🔗', name: 'monzo.me/alex/18.50', sub: 'Waiting on 1 friend', amt: '£18.50' },
            { icon: '🔗', name: 'monzo.me/alex/20.00', sub: 'Shared Airbnb groceries', amt: '£20.00' }
          ]
        },
        'Scheduled': {
          label: 'Automated Rules', metric: '2 Active', cta: '+ Schedule',
          rows: [
            { icon: '🏠', name: 'Rent Transfer', sub: '1st of every month', amt: '£890.00' },
            { icon: '✈️', name: 'Kyoto Auto-Save', sub: 'Every Friday', amt: '£75.00' }
          ]
        }
      }
    },
    cards: {
      title: 'Cards',
      subtabs: ['Physical Coral', 'Virtual Cards', 'Security'],
      views: {
        'Physical Coral': {
          label: 'Hot Coral Debit · •• 4812', metric: 'Active', cta: 'Freeze Card',
          rows: [
            { icon: '💳', name: 'Contactless & Apple Pay', sub: 'Enabled worldwide · 0% FX fee', amt: 'On' },
            { icon: '🏧', name: 'ATM Cash Allowance', sub: '£250 fee-free remaining', amt: '£250' }
          ]
        },
        'Virtual Cards': {
          label: 'Disposable & Pot-Linked', metric: '2 Cards', cta: '+ New Virtual',
          rows: [
            { icon: '🟣', name: 'Subscriptions Virtual', sub: 'Linked to Bills Pot · •• 9021', amt: 'Active' },
            { icon: '🟢', name: 'Travel Booking Card', sub: 'Auto-expires in 12 days', amt: 'Active' }
          ]
        },
        'Security': {
          label: 'Card Protection Controls', metric: 'Protected', cta: 'View PIN',
          rows: [
            { icon: '🌍', name: 'Location-Based Security', sub: 'Matches phone GPS at checkout', amt: 'Enabled' },
            { icon: '🔒', name: 'Magstripe ATM', sub: 'Disabled for safety', amt: 'Off' }
          ]
        }
      }
    }
  };

  let activeTab = 'home';
  let activeSub = 'Overview';

  const viewTitle = document.getElementById('viewTitle');
  const subnavRail = document.getElementById('subnavRail');
  const contentWrap = document.getElementById('contentWrap');
  const tabBtns = [...document.querySelectorAll('.tab-btn')];

  function renderSubnav() {
    const cfg = DATA[activeTab];
    subnavRail.innerHTML = '';
    cfg.subtabs.forEach(sub => {
      const btn = document.createElement('button');
      btn.type = 'button';
      btn.className = 'sub-pill' + (sub === activeSub ? ' active' : '');
      btn.setAttribute('role', 'tab');
      btn.setAttribute('aria-selected', String(sub === activeSub));
      btn.textContent = sub;
      btn.addEventListener('click', () => {
        activeSub = sub;
        renderSubnav();
        renderContent();
      });
      subnavRail.appendChild(btn);
    });
  }

  function renderContent() {
    const cfg = DATA[activeTab];
    const view = cfg.views[activeSub];
    viewTitle.textContent = cfg.title;
    contentWrap.innerHTML = `
      <section class="hero-card">
        <div>
          <small>${view.label}</small>
          <div class="metric">${view.metric}</div>
        </div>
        <button class="hero-cta" type="button">${view.cta}</button>
      </section>
      <section class="list-card">
        ${view.rows.map(r => `
          <div class="list-item">
            <div class="item-left">
              <div class="item-badge">${r.icon}</div>
              <div class="item-info">
                <strong>${r.name}</strong>
                <span>${r.sub}</span>
              </div>
            </div>
            <div class="item-amount ${r.pos ? 'pos' : ''}">${r.amt}</div>
          </div>
        `).join('')}
      </section>
    `;
    const ctaBtn = contentWrap.querySelector('.hero-cta');
    ctaBtn.addEventListener('click', () => {
      const orig = ctaBtn.textContent;
      ctaBtn.textContent = '✓ Action Opened';
      setTimeout(() => { ctaBtn.textContent = orig; }, 1200);
    });
  }

  tabBtns.forEach(btn => {
    btn.addEventListener('click', () => {
      activeTab = btn.dataset.tab;
      activeSub = DATA[activeTab].subtabs[0];
      tabBtns.forEach(b => b.classList.toggle('active', b === btn));
      renderSubnav();
      renderContent();
    });
  });

  renderSubnav();
  renderContent();
})();
</script>
</body>
</html>
```
