CoreModal and CoreModalPage wrap InertiaUI Modal with server-side configuration, automatic title/description injection, and a unified API for both dialogs and sheets.
CoreModalPage (Server-Side)
ReturnCoreModalPage from a controller to configure the modal from the backend. The framework automatically validates the x-inertiaui-modal header and returns a 404 if it’s missing.
Create a modal route
Return
CoreModalPage from your controller with a component name and configuration:The modal now displays as a left-aligned sheet with the specified title, description, and roles data.
CoreModalPage API
Create a new modal page instance. Pass the component path relative to
resources/js/Pages/.Set the modal’s displayed title. Use the
__() helper for translatable strings.Set the modal’s description text shown below the title.
Enable sheet (slideover) mode. Sheets appear as side panels instead of centered dialogs. Optionally set the position in the same call.
Set the sheet position (only works when
sheet() is enabled). Available positions: RIGHT (default), LEFT, TOP, BOTTOM.Pass additional props to the component. All data is available as component props.
Auto-configure modal properties from a domain object. Useful for operations like edit forms.
Opening Modals from React
From a Link
UseCoreModalLink to trigger a modal when users click a button or link:
modalClassName prop accepts Tailwind width classes like max-w-sm, max-w-md, or max-w-2xl to control the modal’s maximum width.
Programmatically
Open modals in response to user actions or events:CoreModal (React Component)
UseCoreModal to wrap your modal content. It automatically reads configuration from pageData (set by CoreModalPage on the server), and lets you override settings with props.
CoreModal Props
Tailwind max-width class to constrain modal width (e.g.,
max-w-sm, max-w-md).Override dialog mode properties including
title, description, and footer.Override sheet mode properties including
side (sheet alignment).CoreTableModal for Bulk Operations
UseCoreTableModal when your modal operates on table rows. It automatically merges IDs from individual row actions and bulk selections, so your components only receive a unified ids array.
CoreTableModal Props
Unique identifier for the modal instance. Used internally to track modal state.
Array of selected item IDs from bulk actions. Passed from the table’s action context.
Render function receiving
{ ids, close }. ids is the merged array of IDs; close() dismisses the modal.Override dialog title, description, and other properties.
ID Merging Behavior
CoreTableModal applies this logic:
- If a
rowActionIdexists (user clicked a row action), use[rowActionId] - Otherwise, use the
selectedItemsarray - Reset
rowActionIdwhen the modal closes
Choosing the Right Modal Component
| Use Case | Component |
|---|---|
| Route-driven modal with server-side configuration | CoreModalPage + CoreModal |
| Click to open modal | CoreModalLink |
| Programmatic modal opening | useModalStack() |
| Table row operations | CoreTableModal |
| Local state modal (not route-driven) | CoreDialog or CoreSheet |
Troubleshooting
Modal not opening
Modal not opening
Ensure the route request includes the
x-inertiaui-modal header. CoreModalLink and useModalStack() add this automatically.TypeError: Passing position() without sheet() throws an exception
TypeError: Passing position() without sheet() throws an exception
Always call
sheet() before position() when configuring sheet modals in CoreModalPage.IDs not merging in CoreTableModal
IDs not merging in CoreTableModal
Verify that
selectedItems is passed from the table’s action context and that name is unique for each modal on the page.Terminology: 'sheet' vs 'slideover'
Terminology: 'sheet' vs 'slideover'
The Core API uses “sheet” terminology, but this maps to InertiaUI’s “slideover” internally. Both refer to the same side panel component.
Advanced Usage
For local state modals that don’t need routing or server configuration, useCoreDialog or CoreSheet directly: