Skip to content

Table with selection and bulk actions in WordPress

An invoice table with checkboxes, a three-state select-all and bulk actions: mark as paid, export to CSV, archive with undo.

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:html -->
<section class="tsa" data-tsa aria-labelledby="tsa-titre">
        <h2 class="tsa-title" id="tsa-titre">Factures d’octobre</h2>
        <div class="tsa-bar" role="toolbar" aria-label="Actions sur la sélection" data-tsa-bar>
          <p class="tsa-count" aria-live="polite" data-tsa-count>Aucune facture sélectionnée</p>
          <div class="tsa-actions">
            <button class="tsa-action" type="button" data-tsa-action="paid" disabled>Marquer comme payées</button>
            <button class="tsa-action" type="button" data-tsa-action="csv" disabled>Exporter en CSV</button>
            <button class="tsa-action" type="button" data-tsa-action="archive" disabled>Archiver</button>
          </div>
        </div>
        <p class="tsa-undo-row" role="status" data-tsa-undo-row hidden><span data-tsa-undo-text></span> <button class="tsa-undo" type="button" data-tsa-undo>Annuler</button></p>
script.js
(() => {
  if (!document.querySelector(".tsa")) return;
  document.querySelectorAll("[data-tsa]").forEach((root) => {
    const on = (el, type, fn) => el.addEventListener(type, fn);
    const all = root.querySelector("[data-tsa-all]");
    const body = root.querySelector("[data-tsa-body]");
    const count = root.querySelector("[data-tsa-count]");
    const undoRow = root.querySelector("[data-tsa-undo-row]");
    const rows = () => [...body.querySelectorAll("[data-tsa-row]")];
    const picked = () => rows().filter((r) => r.querySelector("[data-tsa-pick]").checked);
    let archived = [];
style.css
:root {
  --tsa-card: #ffffff;
  --tsa-text: #172134;
  --tsa-muted: #4a5568;
  --tsa-line: #dce2ea;
  --tsa-head: #f4f6fa;
  --tsa-selected: #eef6ff;
  --tsa-chip: #eef1f6;
  --tsa-paid: #dcfce7;
  --tsa-accent: #1d4ed8;
  --tsa-accent-text: #ffffff;
  --demo-tableau-selection-actions-bg: #eceff4;
tableau-selection-actions.php
<?php
/**
 * Plugin Name: Forge, Tableau avec sélection et actions groupées
 * Description: Un tableau de factures avec cases à cocher, « tout sélectionner » à trois états et actions groupées : marquer payées, exporter en CSV, archiver avec annulation. Ajoute la composition « Tableau avec sélection et actions groupées » à 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-selection-actions
 *

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