Skip to content

Submitting button in WordPress

A button's state while a form is submitting: a small spinner and a "Sending" label.

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

loader-bouton-envoi.php
<?php
/**
 * Plugin Name: Forge, Bouton en cours d'envoi
 * Description: L'état d'un bouton pendant l'envoi d'un formulaire : petit indicateur rotatif et libellé « Envoi en cours ». Ajoute la composition « Bouton en cours d'envoi » à 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-loader-bouton-envoi
 *
pattern.html
<!-- wp:group {"className": "sending", "layout": {"type": "default"}} -->
<div class="wp-block-group sending"><!-- wp:html -->
<button type="button" aria-disabled="true">
          <span class="sending__spinner" aria-hidden="true"></span>
          Envoi en cours…
        </button>
<!-- /wp:html -->
<!-- wp:html -->
<p role="status">Votre demande de devis est en cours d'envoi.</p>
<!-- /wp:html --></div>
<!-- /wp:group -->
style.css
:root {
  --sd-btn: #15803d;
  --sd-btn-text: #ffffff;
  --sd-text: #3d5c48;
  --sd-ring: #14532d;
  --demo-loader-bouton-envoi-bg: #f0fdf4;
  --demo-loader-bouton-envoi-text: #052e16;
}

@media (prefers-color-scheme: dark) {
  :root.forge-follows-system:not([data-theme="light"]) {
    --sd-btn: #86efac;

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

Loaders components in WordPress
  • Three dots bouncing one after another, for a short wait or a message being typed.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A thin bar where a segment slides continuously, for a load of unknown duration.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A spinning ring with a colored segment, alongside a loading text.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component