Tabs

Tabs built on the Radio Hack - hidden radio inputs control panel visibility with pure CSS, plus a Segmented Control variant.

Tabs

We use the so-called Radio Hack. Hidden radio inputs control panel visibility with pure CSS.

This is the content of the first tab. It's instant.
And this is the technical specification in the second tab.
<div class="tabs">
  <!-- Hidden controlling inputs -->
  <input type="radio" name="my-tabs" id="tab-1" class="tab-input" checked>
  <input type="radio" name="my-tabs" id="tab-2" class="tab-input">

  <!-- Headers (labels linked to the inputs) -->
  <div class="tabs-header">
    <label for="tab-1" class="tab-label">Tab 1</label>
    <label for="tab-2" class="tab-label">Tab 2</label>
  </div>

  <!-- Content -->
  <div class="tabs-content">
    <div class="tab-pane">Content 1</div>
    <div class="tab-pane">Content 2</div>
  </div>
</div>

Variant: Segmented Control (sliding pill)

Add the .tabs-pill class alongside .tabs plus style="--tab-count: N;" (number of tabs). Inside .tabs-header add an empty <div class="tabs-pill-indicator"></div> - the indicator sliding and the active label's color happen on their own, in pure CSS (:has(), zero JS).

Statistics for the last day.
Statistics for the last week.
Statistics for the last month.
<div class="tabs tabs-pill" style="--tab-count: 3;">
  <input type="radio" name="my-pill-tabs" id="pt-1" class="tab-input" checked>
  <input type="radio" name="my-pill-tabs" id="pt-2" class="tab-input">
  <input type="radio" name="my-pill-tabs" id="pt-3" class="tab-input">

  <div class="tabs-header">
    <!-- Sliding indicator - always an empty div, no content -->
    <div class="tabs-pill-indicator"></div>
    <label for="pt-1" class="tab-label">Day</label>
    <label for="pt-2" class="tab-label">Week</label>
    <label for="pt-3" class="tab-label">Month</label>
  </div>

  <div class="tabs-content">
    <div class="tab-pane">Content 1</div>
    <div class="tab-pane">Content 2</div>
    <div class="tab-pane">Content 3</div>
  </div>
</div>