Snippets Card

Bootstrap 5 Weather Card with 5-Day Forecast

A weather card with a large current temperature, wind and humidity, and a five-day strip where choosing a day updates the summary above.

Bootstrap 5 No jQuery Dec 2019 2.4K views

<section class="wdw-stage">
  <div class="container" style="max-width: 600px">
    <div class="wdw-card overflow-hidden wdw-weather">
      <div class="wdw-aurora p-4 p-sm-5">
        <div class="d-flex align-items-center gap-2 mb-1">
          <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 21s7-6 7-11a7 7 0 0 0-14 0c0 5 7 11 7 11z"/><circle cx="12" cy="10" r="2.5"/></svg>
          <h1 class="h5 fw-bold mb-0">Moscow</h1>
          <span class="small opacity-75">Red Square · Wednesday</span>
        </div>
        <div class="d-flex align-items-center justify-content-between gap-3 mt-3">
          <div>
            <div class="wdw-temp" id="wxTemp" aria-live="polite">-34°</div>
            <p class="fs-5 fw-semibold mb-2" id="wxCond" aria-live="polite">Partly cloudy</p>
            <div class="d-flex flex-wrap gap-3 small opacity-75">
              <span>Wind <strong class="text-white" id="wxWind">15 km/h</strong></span>
              <span>Humidity <strong class="text-white" id="wxHum">68%</strong></span>
            </div>
          </div>
          <div class="wdw-weather-icon" id="wxIcon" aria-hidden="true"></div>
        </div>
      </div>
      <div class="wdw-days p-2 p-sm-3" role="group" aria-label="Five day forecast, select a day">
        <button type="button" class="wdw-day" aria-pressed="false" data-temp="-30" data-cond="Light snow" data-wind="12 km/h" data-hum="84%" data-icon="snow">
          <span class="wdw-dname fw-semibold">Mon</span><span class="text-primary d-inline-flex"><svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7 15a4 4 0 0 1-.5-7.9A5.5 5.5 0 0 1 17 7.5 4 4 0 0 1 17.5 15z"/><path d="M8 18.5h.01M12 19.5h.01M16 18.5h.01M10 21.5h.01M14 21.5h.01"/></svg></span>
          <span class="wdw-lo">-33°</span>
          <span class="wdw-range" aria-hidden="true"><span style="left:28%;width:20%"></span></span>
          <span class="wdw-hi fw-bold">-28°</span>
        </button>
        <button type="button" class="wdw-day" aria-pressed="false" data-temp="-29" data-cond="Clear and bright" data-wind="8 km/h" data-hum="71%" data-icon="sun">
          <span class="wdw-dname fw-semibold">Tue</span><span class="text-primary d-inline-flex"><svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="4"/><path d="M12 2.5v2M12 19.5v2M5.3 5.3l1.4 1.4M17.3 17.3l1.4 1.4M2.5 12h2M19.5 12h2M5.3 18.7l1.4-1.4M17.3 6.7l1.4-1.4"/></svg></span>
          <span class="wdw-lo">-32°</span>
          <span class="wdw-range" aria-hidden="true"><span style="left:32%;width:24%"></span></span>
          <span class="wdw-hi fw-bold">-26°</span>
        </button>
        <button type="button" class="wdw-day active" aria-pressed="true" data-temp="-34" data-cond="Partly cloudy" data-wind="15 km/h" data-hum="68%" data-icon="partly">
          <span class="wdw-dname fw-semibold">Wed</span><span class="text-primary d-inline-flex"><svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="9" cy="9" r="3"/><path d="M9 2.5v1.2M2.5 9h1.2M4.4 4.4l.9.9M13.6 4.4l-.9.9"/><path d="M7.5 20a4 4 0 0 1-.4-7.98 5.5 5.5 0 0 1 10.5 1.2A3.4 3.4 0 0 1 17 20z"/></svg></span>
          <span class="wdw-lo">-37°</span>
          <span class="wdw-range" aria-hidden="true"><span style="left:12%;width:24%"></span></span>
          <span class="wdw-hi fw-bold">-31°</span>
        </button>
        <button type="button" class="wdw-day" aria-pressed="false" data-temp="-30" data-cond="Overcast" data-wind="10 km/h" data-hum="79%" data-icon="cloud">
          <span class="wdw-dname fw-semibold">Thu</span><span class="text-primary d-inline-flex"><svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7.5 20a4 4 0 0 1-.4-7.98 5.5 5.5 0 0 1 10.5 1.2A3.4 3.4 0 0 1 17 20z"/></svg></span>
          <span class="wdw-lo">-34°</span>
          <span class="wdw-range" aria-hidden="true"><span style="left:24%;width:24%"></span></span>
          <span class="wdw-hi fw-bold">-28°</span>
        </button>
        <button type="button" class="wdw-day" aria-pressed="false" data-temp="-30" data-cond="Snow showers" data-wind="18 km/h" data-hum="88%" data-icon="snow">
          <span class="wdw-dname fw-semibold">Fri</span><span class="text-primary d-inline-flex"><svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7 15a4 4 0 0 1-.5-7.9A5.5 5.5 0 0 1 17 7.5 4 4 0 0 1 17.5 15z"/><path d="M8 18.5h.01M12 19.5h.01M16 18.5h.01M10 21.5h.01M14 21.5h.01"/></svg></span>
          <span class="wdw-lo">-33°</span>
          <span class="wdw-range" aria-hidden="true"><span style="left:28%;width:24%"></span></span>
          <span class="wdw-hi fw-bold">-27°</span>
        </button>
      </div>
      <template data-icon-tpl="snow"><svg width="96" height="96" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path fill="currentColor" stroke="none" d="M7 15a4 4 0 0 1-.5-7.9A5.5 5.5 0 0 1 17 7.5 4 4 0 0 1 17.5 15z"/><path d="M8 18.5h.01M12 19.5h.01M16 18.5h.01M10 21.5h.01M14 21.5h.01" stroke-width="2.4"/></svg></template><template data-icon-tpl="sun"><svg width="96" height="96" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="4.2" fill="currentColor" stroke="none"/><path d="M12 2.5v2M12 19.5v2M5.3 5.3l1.4 1.4M17.3 17.3l1.4 1.4M2.5 12h2M19.5 12h2M5.3 18.7l1.4-1.4M17.3 6.7l1.4-1.4"/></svg></template><template data-icon-tpl="cloud"><svg width="96" height="96" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path fill="currentColor" stroke="none" d="M7.5 20a4 4 0 0 1-.4-7.98 5.5 5.5 0 0 1 10.5 1.2A3.4 3.4 0 0 1 17 20z"/></svg></template><template data-icon-tpl="partly"><svg width="96" height="96" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="9" cy="9" r="3.3" fill="currentColor" fill-opacity=".55" stroke="none"/><path d="M9 2v1.4M2 9h1.4M4 4l1 1M14 4l-1 1M4 14l1-1" stroke-width="1.4"/><path fill="currentColor" stroke="none" d="M7.5 20a4 4 0 0 1-.4-7.98 5.5 5.5 0 0 1 10.5 1.2A3.4 3.4 0 0 1 17 20z"/></svg></template>
    </div>
  </div>
</section>

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