Search 71 components and 72 controllers by name, category or description.
Server-driven UI
Let the controller decide what the page does.
Modals, validation, list updates and toasts from one route, one view and a plain response.
-
1
One view, two presentations
Link with
data-turbo-frame="modal"and the view opens in a modal. Visit the URL directly and the same view renders as a full page.resources/views/tasks/index.blade.php@foreach ($tasks as $task) <a href="{{ route('tasks.edit', $task) }}" data-turbo-frame="modal"> Edit </a> @endforeachresources/views/tasks/edit.blade.php<hw:frame-or-page frame="modal" layout="app"> <hw:modal.title>Edit task</hw:modal.title> <hw:form :action="route('tasks.update', $task)" method="put" track-frame-src> <hw:field name="title" label="Title" required> <hw:input :value="$task->title" /> </hw:field> <hw:button type="submit">Save changes</hw:button> </hw:form> </hw:frame-or-page>Response/frame.html<!-- Turbo asked for the "modal" frame, so only the frame comes back --> <turbo-frame id="modal"> <h2 data-slot="modal-title">Edit task</h2> <form action="/tasks/1" method="post">…</form> </turbo-frame>Opens the real editor in a modal.
Open the editor -
2
Validation stays where the form is
Extend
TurboFormRequestand keeptrack-frame-srcon the form. A failed submit comes back inside the modal, with old input and errors in place.app/Http/Requests/TaskRequest.phpuse Emaia\LaravelHotwireTurbo\Http\Requests\TurboFormRequest; class TaskRequest extends TurboFormRequest { public function rules(): array { return [ 'title' => ['required', 'string', 'max:120'], ]; } }resources/views/tasks/edit.blade.php<hw:frame-or-page frame="modal" layout="app"> <hw:modal.title>Edit task</hw:modal.title> <hw:form :action="route('tasks.update', $task)" method="put" track-frame-src> <hw:field name="title" label="Title" required> <hw:input :value="$task->title" /> </hw:field> <hw:button type="submit">Save changes</hw:button> </hw:form> </hw:frame-or-page>Response/422 frame.html<!-- The same frame, re-rendered with old input and the error --> <turbo-frame id="modal"> <input name="title" value="" aria-invalid="true"> <p data-slot="field-error">The title field is required.</p> </turbo-frame>Save an empty title, then a valid one.
Open the editor -
3
Answer with what changed
Replace the row, close the modal that submitted and confirm with a toast. Without JavaScript the same action redirects, and the toast still arrives.
app/Http/Controllers/TaskController.phppublic function update(TaskRequest $request, Task $task): mixed { $task->update($request->validated()); if ($origin = $request->overlayOrigin()) { return turbo_stream() ->replace($task, view('tasks._card', compact('task'))) ->closeOverlay($origin) ->toast('success', 'Task updated'); } return to_route('tasks.show', $task) ->toast('success', 'Task updated'); }Response/turbo-stream.html<turbo-stream action="replace" target="task_1"> <template><article id="task_1">…</article></template> </turbo-stream> <turbo-stream action="hotwire-overlay-close" target="modal"> <template></template> </turbo-stream> <turbo-stream action="append" target="toaster"> <template> <div data-controller="toast" data-toast-message-value="Task updated" data-toast-type-value="success"></div> </template> </turbo-stream>Save a valid title and watch the three streams land.
Open the editor -
4
Ask only when it matters
The server knows when a delete needs a second look. If the task has subtasks, the action answers with a confirmation instead of deleting.
app/Http/Controllers/TaskController.phppublic function destroy(Request $request, Task $task): mixed { if ($task->subtasks()->exists() && ! $request->boolean('confirmed')) { return response()->modal()->open( view('tasks._confirm-destroy', compact('task')), source: route('tasks.confirm-destroy', $task), ); } $task->delete(); $streams = turbo_stream()->remove($task)->toast('success', 'Task deleted'); if ($origin = $request->overlayOrigin()) { $streams->closeOverlay($origin); } return $streams; }resources/views/tasks/_confirm-destroy.blade.php<hw:modal.header> <hw:modal.title>Delete “Write launch notes”?</hw:modal.title> <hw:modal.description> The server found 3 subtasks under this task. They will be deleted with it. </hw:modal.description> </hw:modal.header> <hw:form id="demo-confirm-destroy" :action="route('components.server-driven-ui.demo.destroy')" method="post"> <input type="hidden" name="confirmed" value="1"> </hw:form> <hw:modal.footer> <hw:modal.close>Keep task</hw:modal.close> <hw:button type="submit" variant="destructive" form="demo-confirm-destroy">Delete with subtasks</hw:button> </hw:modal.footer>Response/turbo-stream.html<!-- First submit: the server opens a confirmation instead of deleting --> <turbo-stream action="hotwire-overlay-open" target="modal" data-overlay-family="modal" data-overlay-source="/tasks/1/confirm-destroy"> <template>…confirmation…</template> </turbo-stream>Delete a demo task that has 3 subtasks.
-
5
Feel instant, stay correct
Show the task as done the moment it is clicked. The server response reconciles it, and a rejected change rolls back to the real state.
resources/views/tasks/_card.blade.php<hw:form :action="route('tasks.complete', $task)" method="patch" data-controller="optimistic--form"> <hw:optimistic :target="dom_id($task, 'status')" action="update"> <hw:badge>Done</hw:badge> </hw:optimistic> <hw:button type="submit" size="sm">Mark as done</hw:button> </hw:form>Includes an update the server rejects.
Try it
What doesn't change
- Routes and route model binding
- Form Requests and policies
- Redirects and flash messages
- Works without JavaScript
When the browser needs behavior
Masks, uploads, hotkeys and charts live in Stimulus controllers — lazy-loaded and yours to extend.