Skip to content

Service price list with tabs in WordPress

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

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

Open in a new tab

The code in WordPress

onglets-faq-tarifs-prestations.php
<?php
/**
 * Plugin Name: Forge, Grille tarifaire par prestation
 * Description: Des tarifs indicatifs rangés par corps de métier dans des onglets, avec l'unité de chaque prestation, une bascule TTC / HT et la mention « devis gratuit ». Ajoute la composition « Grille tarifaire par prestation » à 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-faq-tarifs-prestations
 *
pattern.html
<!-- wp:html -->
<section class="gtp" data-gtp data-gtp-rate="10" aria-labelledby="gtp-title">
        <header class="gtp__head">
          <div>
            <h2 class="gtp__title" id="gtp-title">Nos tarifs indicatifs</h2>
            <p class="gtp__intro">Rénovation intérieure par corps de métier, à l'heure, au forfait ou au mètre carré.</p>
          </div>
          <p class="gtp__badge"><svg viewBox="0 0 20 20" width="18" height="18" aria-hidden="true"><path d="m5 10.5 3.2 3.2L15 6.8" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/></svg>Devis gratuit et sans engagement</p>
        </header>
        <div class="gtp__bar">
          <div class="gtp__tabs" role="tablist" aria-label="Corps de métier" hidden>
          <button class="gtp__tab" type="button" role="tab" id="gtp-tab-plomberie" aria-controls="gtp-panel-plomberie" aria-selected="true">Plomberie</button>
script.js
(() => {
  if (!document.querySelector(".gtp")) return;
  document.querySelectorAll("[data-gtp]").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 toggle = root.querySelector("[data-gtp-toggle]");
    const modes = [...toggle.querySelectorAll("[data-gtp-mode]")];
    const status = root.querySelector("[data-gtp-status]");
    const rate = Number(root.dataset.gtpRate);
    const money = (value) =>
      new Intl.NumberFormat("fr-FR", {
style.css
:root {
  --gtp-surface: #ffffff;
  --gtp-text: #1f1a17;
  --gtp-muted: #5c524b;
  --gtp-line: #eaded3;
  --gtp-row: #f1e7de;
  --gtp-tab-line: #e2d3c6;
  --gtp-accent: #9a3412;
  --gtp-accent-hover: #7c2d12;
  --gtp-on-accent: #ffffff;
  --gtp-unit-bg: #fbe9dc;
  --gtp-unit-text: #7c2d12;

Free component: copy it freely, including for commercial projects.

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
    Component
  • Understated tabs with an underlined active tab, to organize the information on a product page.

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

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

    • Tailwind
    • React
    • CSS
    • WordPress
    Component