Introduction
Inertia Forms is part of Inertia UI, a suite of packages designed for Laravel, Inertia.js, and Tailwind CSS. It lets you define forms entirely in PHP and render them automatically with the frontend package for your stack.
The package ships with matching Vue 3.5+ and React 19 packages. The same PHP Form class drives both frontends, so the only difference is whether your page imports from @inertiaui/form-vue or @inertiaui/form-react.
The whole workflow is three steps: define your fields in PHP, pass the form to your Inertia page, and render it with a single component.
Quick Example
Here's a complete form, from the backend to the frontend. First, define a form class:
use App\Models\Role;
use InertiaUI\Forms\Fields\Combobox;
use InertiaUI\Forms\Fields\Submit;
use InertiaUI\Forms\Fields\TextInput;
use InertiaUI\Forms\Form;
class CreateUserForm extends Form
{
protected ?string $actionRoute = 'users.store';
public function fields(): array
{
return [
TextInput::make('name')
->required()
->precognitive(),
TextInput::make('email')
->email()
->required(),
Combobox::make('role')->options(Role::pluck('name', 'id')),
Submit::make('Create User'),
];
}
}Next, pass it to your page from a controller:
use App\Forms\CreateUserForm;
use Inertia\Inertia;
return Inertia::render('Users/Create', [
'form' => CreateUserForm::make(),
]);Finally, render it in your frontend:
<script setup>
import { Form } from '@inertiaui/form-vue'
defineProps(['form'])
</script>
<template>
<Form :form="form" />
</template>import { Form } from '@inertiaui/form-react'
export default function CreateUser({ form }) {
return <Form form={form} />
}With one PHP class and one frontend component, you get a fully functional, styled form with validation, error handling, and submission wired up automatically.
Features
Inertia Forms covers the following:
- Define fields, validation, labels, help text, layout, and submit behavior in a Laravel form class.
- Render the same serialized form through the Vue or React package for your stack.
- Use the included text, URL, choice, record, date/time, color, slider, upload, editor, composer, collection, block, key/value, OTP, display helper, fieldset, and submit controls.
- Generate Laravel rules from the field configuration, and validate selected fields on blur with Precognition.
- Show, hide, and clear fields or fieldsets based on other field values.
- Upload files with temporary uploads, chunked uploads, direct-to-storage uploads, previews, reordering, and Spatie Media Library integration.
- Bind an Eloquent model or array and let fields read their initial values from it.
- Gate the visibility of fields and forms, and customize the generated markup with presentation options and Tailwind theme tokens.
- Render the exported Vue and React controls directly when a form section shouldn't come from a PHP payload.
- Add macros, register custom fields, or clone built-in presenters with hooks and composables.
How It Works
Inertia Forms follows a short pipeline:
- You define a
Formclass with afieldsmethod that returns an array of field instances. - The
Form::makemethod creates the form, which serializes to a JSON-friendly array through itstoArraymethod. - Inertia passes this array as a prop to your page.
- The
<Form>component reads the field definitions and renders the matching input component for each one. - On submit, the form posts to your action route using Inertia's form helper.
You define the structure in PHP. The frontend package handles the UI: input rendering, error display, validation triggers, loading states, and form submission.
Next Steps
- Check the Requirements for your stack.
- Follow the Installation guide to get started.
- Read Basic Usage for a complete walkthrough.