This document describes how to use a reusable Blade modal component.
<x-dialog
name="playlist-modal"
title="Select a song"
fixed-height="md"
content:class="space-y-2"
>
<p>Choose one of the songs below.</p>
</x-dialog><x-dialog> wraps a flux:modal and renders three main areas:
- Title bar (header with title + close button)
- Scrollable content (your default slot)
- Footer (cancel button + optional custom action buttons, can be hidden)
The modal is rendered with :closable="false", so close behavior is handled via the built-in close buttons.
| Prop | Type | Default | Description |
|---|---|---|---|
name |
string | modal |
Required unique modal name/id for Flux modal targeting. |
title |
string | config('app.name') |
Header title text. |
buttons |
named slot content (<x-slot name="buttons">) |
null |
Optional custom footer actions rendered on the right (next to cancel). |
extraHeader |
named slot content (<x-slot name="extraHeader">) |
null |
Optional content rendered directly under the title bar. |
color |
string | zinc |
Base color variant used for title/content/footer backgrounds. |
cancelText |
string | Close |
Label for the default cancel/close button in the footer. |
fixedHeight |
string | '' |
Optional fixed content area height preset. |
showFooter |
bool | true |
Show or hide the entire footer section. |
buttons and extraHeader are typically provided as named slots inside <x-dialog>, not as scalar string props.
The component supports scoped attribute forwarding:
title:*-> applies to the title bar wrapperwrapper:*-> applies to the outer modal body wrappercontent:*-> applies to the scrollable content areafooter:*-> applies to the footer bar
Color targeting is also supported:
color:title="..."-> overrides title bar color onlycolor:content="..."-> overrides content background color onlycolor:footer="..."-> overrides footer background color only
Most commonly, you will use *:class to add utility classes:
<x-dialog
name="user-details"
title="User Details"
wrapper:class="max-w-3xl"
title:class="text-slate-900"
content:class="space-y-4"
footer:class="bg-slate-50"
>
...
</x-dialog>The component now exposes stable data attributes on key wrapper elements so you can target them from global CSS when utility classes are not enough:
data-dialog-wrapper-> outer dialog body wrapperdata-dialog-title-> title bar containerdata-dialog-content-> scrollable content areadata-dialog-footer-> footer container (whenshowFooteris true)
Example:
<style>
[data-dialog-content] {
background-color: red;
}
[data-dialog-title] [data-flux-heading] {
color: red;
}
</style>Flux components (including the modal shell itself) also add their own data-flux-* attributes. You can combine dialog-level and Flux-level selectors for precise targeting.
The component supports Tailwind's 4.2 color names for color, color:title, color:content, and color:footer, with a default of zinc.
Depending on your project's standards, you may want to remove unwanted colors, and/or adjust the colors.
Use kebab-case in Blade (fixed-height), mapped to fixedHeight internally.
fixed-height |
Content area height |
|---|---|
xs |
20vh |
sm |
40vh |
md |
50vh |
lg |
60vh |
xl |
70vh |
2xl |
80vh |
If you want to set a custom height, set min-height and max-height on the content area to the same value.
E.g. content:style="min-height: 400px; max-height: 400px;" or content:class="max-h-32 min-h-32"
This is required to overrule the default flexbox
flex-x/shrinkbehavior of the default wrapper.
If omitted, content height is flexible and constrained by modal max height.
Use a named slot (buttons) to append action buttons in the footer. These render to the right of the default cancel button.
<x-dialog name="edit-talk" :title="$mode === 'update' ? 'Update Talk' : 'Create Talk'">
<form id="edit-form" wire:submit="save">
...
</form>
<x-slot name="buttons">
<flux:button variant="filled" wire:click="clearForm" size="sm">Reset</flux:button>
<flux:button type="submit" form="edit-form" variant="primary" color="sky" size="sm">
{{ $mode === 'update' ? 'Save Talk' : 'Create Talk' }}
</flux:button>
</x-slot>
</x-dialog>The
buttonsslot is rendered outside the content area, so you have to use anidon your form andform="..."on your submit button to link them.
- Set
:show-footer="false"to hide the entire footer block. - Set
cancel-text=""to hide only the cancel button while still rendering custombuttons.
Use extraHeader for helper text, tabs, filters, or context directly below the title bar:
<x-dialog
name="search-modal"
title="Advanced Search"
>
<x-slot name="extraHeader">
<flux:input type="search" placeholder="Search speakers..." size="sm" />
</x-slot>
...
</x-dialog><x-dialog
name="playlist-modal"
title="Select a song"
color="indigo"
color:content="zinc"
color:footer="sky"
fixed-height="md"
cancel-text="Cancel"
content:class="space-y-2"
title:class="text-slate-900"
>
<ul class="space-y-2">
<li>Song A</li>
<li>Song B</li>
<li>Song C</li>
</ul>
</x-dialog>A flyout modal is partially supported.
<x-dialog
name="playlist-modal"
title="Select a song"
flyout
position="left"
>
...
</x-dialog>In flyout mode, the modal and wrapper use full viewport height and the title/footer become sticky.
position="bottom" and variant="floating" are not supported (an InvalidArgumentException is thrown).
- The top-right icon close button and footer cancel button both close the modal.
- Default wrapper classes include
overflow-hidden p-0!onflux:modaland amax-h-[80vh]flex column wrapper. - Content area is scrollable (
overflow-y-auto) by default.