markwalet/nova-modal-response

A Laravel Nova asset for Modal responses on an action.

Maintainers

Package info

github.com/markwalet/nova-modal-response

pkg:composer/markwalet/nova-modal-response

Fund package maintenance!

markwalet

www.paypal.me/markwalet

Statistics

Installs: 812 983

Dependents: 0

Suggesters: 0

Stars: 15

Open Issues: 15


README

Build Status Total Downloads Latest Stable Version License

Enabling custom modals for action responses in Laravel Nova.

Example screenshot

More info for this specific feature can be found in the Nova Documentation.

Installation

composer require markwalet/nova-modal-response

This package requires PHP 8.2+ and Laravel 12+.

Usage

use Markwalet\NovaModalResponse\ModalResponse;

ModalResponse::text('This is way better than that small notification in the bottom right!')
    ->title('Result in a modal');

Note: Always build responses through the ModalResponse helper. Hand-rolling the raw payload with Action::modal('modal-response', [...]) is not a supported part of this package's API and may break without notice.

When you want to render raw html, you can use the html parameter instead:

ModalResponse::html('<ul><li>Show this package to your friends</li><li>Contribute</li><li>???</li><li>Profit!</li></ul>');

There is also a special mode for rendering code snippets. This will surround the body with a <pre> and <code> tag but still leave escaping enabled.

ModalResponse::code(file_get_contents(__FILE__))->title('Look at me!');

Syntax highlighting is enabled by default for code and json blocks. It is using highlight.js under the hood. You can disable this by calling ->withoutSyntaxHighlighting().

If you want to show some serializable data to the client, you can do that as well:

ModalResponse::json([
    'lorem' => 'ipsum',
    'dolor' => [
        'sit',
        'amet',
    ],
]);

You can also specify the size using the size option:

ModalResponse::text('Hello world')->size('7xl');