Snippets Card

Bootstrap 5 Weather Card with Live Time and Date

A weather card for one city showing the current temperature, conditions, high and low, and a live clock and date.

Bootstrap 5 No jQuery Dec 2019 3K views

<section class="wdw-stage">
  <div class="container" style="max-width:600px">
    <article class="wx wdw-aurora rounded-5 p-4 p-sm-5" aria-label="Weather in Toronto">
      <div class="row g-4 align-items-stretch">
        <div class="col-12 col-sm-6 d-flex flex-column">
          <p class="mb-0 fw-semibold opacity-75 small text-uppercase" style="letter-spacing:.08em">Now in</p>
          <h2 class="h3 fw-bold mb-0">Toronto</h2>
          <p class="mb-0 opacity-75 d-flex align-items-center gap-2">
            <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 17.6A4.5 4.5 0 0 0 18 9h-1.3A7 7 0 1 0 4 15.3"/><path d="M8 16h.01M8 20h.01M12 18h.01M12 22h.01M16 16h.01M16 20h.01"/></svg>
            Light snow
          </p>
          <p class="wx-temp fw-bold mb-0 mt-auto pt-4">−20°</p>
        </div>
        <div class="col-12 col-sm-6 d-flex flex-column justify-content-between wx-side">
          <ul class="list-unstyled small mb-4 d-grid gap-2">
            <li class="d-flex justify-content-between"><span class="opacity-90">High</span><span class="fw-semibold">−14°</span></li>
            <li class="d-flex justify-content-between"><span class="opacity-90">Low</span><span class="fw-semibold">−23°</span></li>
            <li class="d-flex justify-content-between"><span class="opacity-90">Feels like</span><span class="fw-semibold">−27°</span></li>
          </ul>
          <div class="pt-3 border-top border-light border-opacity-25">
            <span class="visually-hidden">Local time in Toronto</span>
            <time class="wx-time fw-bold d-block" id="wxTime"><span id="wxClock">--:--</span> <span class="fs-6 fw-semibold opacity-90" id="wxAmPm"></span></time>
            <p class="mb-0 opacity-90 small" id="wxDate"> </p>
          </div>
        </div>
      </div>
    </article>
  </div>
</section>

Built on Bootstrap 5.3.8 with plain JavaScript — no jQuery. Supports light and dark mode via data-bs-theme.

Free to use in personal and commercial projects under the MIT license.