Seasonal opening hours in WordPress
Two tabs to show different opening hours by season, in a compact card.
Here is an excerpt of this component's code in WordPress. The full code is free for members, ready to copy into your project.
This component also comes in
The code in WordPress
<?php
/**
* Plugin Name: Forge, Horaires par saison
* Description: Deux onglets pour afficher des horaires d'ouverture différents selon la saison, dans une carte compacte. Ajoute la composition « Horaires par saison » à l'éditeur de blocs.
* Version: 1.0.0
* Requires at least: 6.6
* Requires PHP: 8.1
* Author: Forge
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: forge-onglets-horaires-saison
*<!-- wp:html -->
<div class="stabs" data-tabs>
<h2>Horaires du fournil</h2>
<div class="stabs__list" role="tablist" aria-label="Période" hidden>
<button class="stabs__tab" type="button" role="tab" id="onglets-horaires-saison-tab-1" aria-selected="true" aria-controls="onglets-horaires-saison-panel-1">Haute saison</button>
<button class="stabs__tab" type="button" role="tab" id="onglets-horaires-saison-tab-2" aria-selected="false" aria-controls="onglets-horaires-saison-panel-2" tabindex="-1">Basse saison</button>
</div>
<div class="stabs__panel" role="tabpanel" id="onglets-horaires-saison-panel-1" aria-labelledby="onglets-horaires-saison-tab-1" tabindex="0">
<p>Du 1er juin au 15 septembre</p>
<dl>
<div><dt>Lundi au vendredi</dt><dd>7 h – 19 h 30</dd></div>
<div><dt>Samedi</dt><dd>7 h – 20 h</dd></div>(() => {
if (!document.querySelector(".stabs")) return;
document.querySelectorAll("[data-tabs]").forEach((root) => {
const list = root.querySelector('[role="tablist"]');
const tabs = [...list.querySelectorAll('[role="tab"]')];
const panels = tabs.map((tab) => document.getElementById(tab.getAttribute("aria-controls")));
const vertical = list.getAttribute("aria-orientation") === "vertical";
function select(index, focus) {
tabs.forEach((tab, position) => {
const selected = position === index;
tab.setAttribute("aria-selected", String(selected));:root {
--st-onglets-horaires-saison-card: #ffffff;
--st-onglets-horaires-saison-text: #2b1a0e;
--st-onglets-horaires-saison-muted: #6b4a33;
--st-onglets-horaires-saison-line: #ead9c6;
--st-onglets-horaires-saison-track: #f5e6d3;
--st-onglets-horaires-saison-active: #8a4b1f;
--st-onglets-horaires-saison-active-text: #ffffff;
--st-onglets-horaires-saison-ring: #8a4b1f;
--demo-onglets-horaires-saison-bg: #fbf6f0;
--demo-onglets-horaires-saison-text: #2b1a0e;
}Free component: copy it freely, including for commercial projects.
Other tabs components in WordPress
Tabs components in WordPress
Accessible tabs on large screens that turn into an accordion on phones, with the right ARIA roles in each mode.
- Tailwind
- React
- CSS
- WordPress

Indicative prices sorted by trade in tabs, with the unit of each service, a VAT-inclusive / excl. switch and a free-quote notice.
- Tailwind
- React
- CSS
- WordPress

Underlined tabs
FreeUnderstated tabs with an underlined active tab, to organize the information on a product page.
- Tailwind
- React
- CSS
- WordPress

A dark code block with one tab per package manager, for technical documentation.
- Tailwind
- React
- CSS
- WordPress