Search by

23vbq / top-layer-bundle

23vbq

Native <dialog> modals, drawers and toasts for Symfony with Turbo and Stimulus

Package info

github.com/23vbq/top-layer-bundle

Type:symfony-bundle

pkg:composer/23vbq/top-layer-bundle

Statistics

Installs: 40

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 3

v0.2.1 2026-11-26 21:55 UTC

This package is auto-updated.

Last update: 2026-11-26 21:55:37 UTC


README

Native <dialog> modals, drawers and toasts for Symfony with Turbo and Stimulus.

Status

Work in progress, not yet released. The API is not stable and may change at any time.

Why native <dialog>

  • Top layer - modals opened with showModal() and popovers are rendered in the browser's top layer, above the rest of the page.
  • No z-index - the top layer sits above all other content, so there is no z-index stacking to manage.
  • Built-in backdrop - the ::backdrop pseudo-element provides an overlay without extra markup.
  • Focus trap and Escape - modal dialogs make the rest of the page inert, keep focus inside the dialog and close on Escape out of the box.

Installation

composer require 23vbq/top-layer-bundle

The bundle requires Turbo 8 (@hotwired/turbo ^8.0). With AssetMapper, check the version in importmap.php.

Quick start

Place a modal and the button that opens it inside an element with the bundle's Stimulus controller:

<div data-controller="23vbq--top-layer-bundle--dialog">
    <button type="button"
            data-action="23vbq--top-layer-bundle--dialog#open"
            data-23vbq--top-layer-bundle--dialog-src-param="{{ path('employee_delete', {id: employee.id}) }}">
        Delete
    </button>

    <twig:TopLayer:Modal id="modal-employee-action" frame="employee-action" title="Delete employee" />
</div>

Clicking the button loads the URL into the modal. The page behind it renders its content inside a matching <turbo-frame>:

<turbo-frame id="employee-action">
    {# form, confirmation, ... #}
</turbo-frame>

Documentation

  • Modal and drawer - components, props, opening and closing
  • Turbo Stream actions - closing dialogs and reloading frames from a server response
  • Toasts - flash-based notifications, configuration, toasts above modals
  • Styling - CSS variables, dark mode, overriding classes and templates