Basics
To create modal windows, the moonshine::modal
component is used.
<x-moonshine::modal title="Title"> <div> Content... </div> <x-slot name="outerHtml"> <x-moonshine::link-button @click.prevent="toggleModal"> Open modal </x-moonshine::link-button> </x-slot></x-moonshine::modal>
Wide window
The wide
parameter allows modal windows to fill the entire width.
<x-moonshine::modal wide title="Title"> <div> Content... </div> <x-slot name="outerHtml"> <x-moonshine::link-button @click.prevent="toggleModal"> Open wide modal </x-moonshine::link-button> </x-slot></x-moonshine::modal>
Automatic width
The auto
parameter allows modal windows to take up width based on the content.
<x-moonshine::modal auto title="Title"> <div> Content... </div> <x-slot name="outerHtml"> <x-moonshine::link-button @click.prevent="toggleModal"> Open auto modal </x-moonshine::link-button> </x-slot></x-moonshine::modal>
Closing a window
By default, modal windows close when clicked outside the window area. You can override this behavior using the closeOutside
parameter.
<x-moonshine::modal :closeOutside="false" title="Title"> <div> Content... </div> <x-slot name="outerHtml"> <x-moonshine::link-button @click.prevent="toggleModal"> Open modal </x-moonshine::link-button> </x-slot></x-moonshine::modal>
Asynchronous Content
The moonshine::modal
component allows you to load content asynchronously.
<x-moonshine::modal async :asyncUrl="route('async')" title="Title"> <x-slot name="outerHtml"> <x-moonshine::link-button @click.prevent="toggleModal"> Open async modal </x-moonshine::link-button> </x-slot></x-moonshine::modal>