Skip to content

Renovation project card in WordPress

A finished-project card with a before / after toggle, location, duration, type of work, indicative budget and a link to the details.

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

carte-realisation-avant-apres.php
<?php
/**
 * Plugin Name: Forge, Carte de réalisation chantier
 * Description: Une carte de chantier terminé avec bascule avant / après, lieu, durée, type de travaux, budget indicatif et lien vers le détail. Ajoute la composition « Carte de réalisation chantier » à 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-carte-realisation-avant-apres
 *
pattern.html
<!-- wp:group {"tagName": "section", "className": "crav", "layout": {"type": "default"}} -->
<section class="wp-block-group crav"><!-- wp:group {"tagName": "header", "className": "crav__header", "layout": {"type": "default"}} -->
<header class="wp-block-group crav__header"><!-- wp:heading {"level": 2, "className": "crav__heading", "anchor": "crav-titre"} -->
<h2 class="wp-block-heading crav__heading" id="crav-titre">Nos chantiers terminés</h2>
<!-- /wp:heading -->
<!-- wp:paragraph {"className": "crav__intro"} -->
<p class="crav__intro">Comparez l’avant et l’après de nos dernières réalisations. Les budgets sont indicatifs, fournitures et pose comprises.</p>
<!-- /wp:paragraph --></header>
<!-- /wp:group -->
<!-- wp:html -->
<ul class="crav__list">
          <li>
script.js
(() => {
  if (!document.querySelector(".crav")) return;
  document.querySelectorAll("[data-crav]").forEach((card) => {
    const toggle = card.querySelector("[data-crav-toggle]");
    const buttons = toggle.querySelectorAll("[data-crav-view]");
    const shots = card.querySelectorAll("[data-crav-shot]");

    function show(view) {
      shots.forEach((shot) => {
        shot.dataset.state = shot.dataset.cravShot === view ? "on" : "off";
      });
      buttons.forEach((button) => {
style.css
:root {
  --crav-surface: #ffffff;
  --crav-text: #1f2328;
  --crav-muted: #57606a;
  --crav-line: #d8dee4;
  --crav-media: #e7e2da;
  --crav-accent: #9a3412;
  --crav-accent-hover: #7c2d12;
  --crav-kind-bg: #fdebdd;
  --crav-kind-text: #7c2d12;
  --crav-pill-bg: rgb(255 255 255 / 0.95);
  --crav-pill-text: #1f2328;

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

Cards components in WordPress
  • A single-plan pricing card: struck-through price and discount, a places-left gauge driven by a data attribute, the list of everything included and a booking button that turns into a waiting list once sold out.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • Three treatment cards in accessible neumorphism: gently raised surfaces, buttons that sink in when activated, a light/dark switch for the block itself. 3:1 outlines and AA text kept.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • Four fully clickable workshop cards in a neo-brutalist style: thick border, solid offset shadow and a card that sinks onto its shadow on hover or focus. Pastel tones, dark mode, no JavaScript.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • Three brutalist service cards: one-pixel border, hard offset shadow that lifts on hover and sinks on click, large type, accent and dark variants. No JavaScript.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A mobile page to link from your social profiles: portrait, name, priority links (booking, WhatsApp, website, reviews, call), opening hours with an open or closed status, social links and a share button, in dependency-free HTML and CSS.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A seasonal promotion card with a struck-through price and discount that announces by itself whether the offer is coming, how many days are left or that it is over.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component