Skip to content

Table that turns into cards on mobile in WordPress

A real table on large screens whose rows each become a readable card on mobile, with no horizontal scrolling and no JavaScript.

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

pattern.html
<!-- wp:group {"className": "mtab", "layout": {"type": "default"}} -->
<div class="wp-block-group mtab"><!-- wp:html -->
<table>
            <caption>Planning de la semaine<span>Cours de 60 à 75 minutes, tapis fournis.</span></caption>
            <thead>
              <tr>
                <th scope="col">Cours</th>
                <th scope="col">Jour</th>
                <th scope="col">Horaire</th>
                <th scope="col">Avec</th>
                <th scope="col">Niveau</th>
                <th scope="col">Places</th>
style.css
:root {
  --mtab-text: #24163a;
  --mtab-muted: #5b4a72;
  --mtab-card: #ffffff;
  --mtab-line: #e4daf1;
  --mtab-head-line: #d9cdea;
  --mtab-badge: #ede5f8;
  --mtab-badge-text: #5b21b6;
  --mtab-full: #fde8e8;
  --mtab-full-text: #9b1c1c;
  --demo-tableau-cartes-mobile-bg: #f8f5fc;
  --demo-tableau-cartes-mobile-text: #24163a;
tableau-cartes-mobile.php
<?php
/**
 * Plugin Name: Forge, Tableau en cartes sur mobile
 * Description: Un vrai tableau sur grand écran dont chaque ligne devient une carte lisible sur mobile, sans défilement horizontal ni JavaScript. Ajoute la composition « Tableau en cartes sur mobile » à 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-tableau-cartes-mobile
 *

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

Data tables components in WordPress
  • A documentation table showing where a kit or component has been tested (static HTML, WordPress, Elementor, Webflow, v0…), with status, last test date and a remark, filterable by status.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A table of the towns and postcodes a tradesperson covers, with response time and travel fee, filtered by search and by zone.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A timetable table sorted by column and filtered with level and free-place chips, whose rows each become a card on phones.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A filterable table whose visible rows export in one click to a CSV file that opens cleanly in Excel or LibreOffice.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A price table by service: one package to pick, options to tick, and the total with the estimated time recalculated on every click.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A product spec sheet as two-column tables in native collapsible sections, with a button to open or close them all.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component