Full-screen search in WordPress
A search covering the page, with popular suggestions, opened from the navigation bar.
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
The code in WordPress
<?php
/**
* Plugin Name: Forge, Recherche plein écran
* Description: Une recherche qui recouvre la page, avec suggestions populaires, ouverte depuis la barre de navigation. Ajoute la composition « Recherche plein écran » à 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-modale-recherche-plein-ecran
*<!-- wp:html -->
<button type="button" class="search-trigger" data-dialog-open="search-overlay">
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="m20 20-4.5-4.5M17 10.5a6.5 6.5 0 1 1-13 0 6.5 6.5 0 0 1 13 0Z"/></svg>
Rechercher
</button>
<!-- /wp:html -->
<!-- wp:html -->
<dialog id="search-overlay" class="overlay-search" aria-label="Recherche sur le site">
<div class="overlay-search__inner">
<button type="button" class="overlay-search__close" data-dialog-close>Fermer</button>
<form role="search" action="#resultats">(() => {
if (!document.querySelector(".search-trigger")) return;
document.querySelectorAll("[data-dialog-open]").forEach((button) => {
const dialog = document.getElementById(button.dataset.dialogOpen);
button.addEventListener("click", () => dialog.showModal());
});
document.querySelectorAll("dialog").forEach((dialog) => {
dialog.addEventListener("click", (event) => {
if (event.target === dialog) dialog.close();
});
dialog.querySelectorAll("[data-dialog-close]").forEach((button) => {:root {
--search-bg: #f7f3ec;
--search-text: #2b241b;
--search-muted: #6b5d4a;
--search-line: #2b241b;
--search-chip: #ebe3d6;
--search-ring: #2b241b;
--demo-modale-recherche-plein-ecran-bg: #f7f3ec;
--demo-modale-recherche-plein-ecran-text: #2b241b;
}
@media (prefers-color-scheme: dark) {Free component: copy it freely, including for commercial projects.
Other modals components in WordPress
Modals components in WordPress
Age verification
FreeA legal-age check window for a wine shop or brewery, accessible, remembered for the session and with the French Evin law notices.
- Tailwind
- React
- CSS
- WordPress

A short form in a window to request a call from an advisor.
- Tailwind
- React
- CSS
- WordPress

A small window asking to confirm an action before running it.
- Tailwind
- React
- CSS
- WordPress