Underlined tabs in WordPress
Understated tabs with an underlined active tab, to organize the information on a product page.
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, Onglets soulignés
* Description: Des onglets sobres dont l'onglet actif est souligné, pour organiser les informations d'une fiche produit. Ajoute la composition « Onglets soulignés » à 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-soulignes
*<!-- wp:html -->
<div class="utabs" data-tabs>
<div class="utabs__list" role="tablist" aria-label="Informations sur le produit" hidden>
<button class="utabs__tab" type="button" role="tab" id="onglets-soulignes-tab-1" aria-selected="true" aria-controls="onglets-soulignes-panel-1">Description</button>
<button class="utabs__tab" type="button" role="tab" id="onglets-soulignes-tab-2" aria-selected="false" aria-controls="onglets-soulignes-panel-2" tabindex="-1">Dimensions</button>
<button class="utabs__tab" type="button" role="tab" id="onglets-soulignes-tab-3" aria-selected="false" aria-controls="onglets-soulignes-panel-3" tabindex="-1">Livraison et retours</button>
</div>
<div class="utabs__panel" role="tabpanel" id="onglets-soulignes-panel-1" aria-labelledby="onglets-soulignes-tab-1" tabindex="0">
<p>Sac cabas en toile de coton biologique épaisse (420 g/m²), anses en cuir tanné végétal et poche intérieure zippée. Fabriqué dans notre atelier de Roanne.</p>
</div>
<div class="utabs__panel" role="tabpanel" id="onglets-soulignes-panel-2" aria-labelledby="onglets-soulignes-tab-2" tabindex="0">
<ul>(() => {
if (!document.querySelector(".utabs")) 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 {
--ut-text: #0b1b3a;
--ut-muted: #46577a;
--ut-line: #d6e0f5;
--ut-active: #1d4ed8;
--ut-ring: #1d4ed8;
--demo-onglets-soulignes-bg: #f8faff;
--demo-onglets-soulignes-text: #0b1b3a;
}
@media (prefers-color-scheme: dark) {
:root.forge-follows-system:not([data-theme="light"]) {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

Two tabs to show different opening hours by season, in a compact card.
- Tailwind
- React
- CSS
- WordPress

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