Form
A form wrapper that emits CSRF, spoofs PUT/PATCH/DELETE, switches to multipart for file uploads, and renders an optional validation error summary.
Preview
Controls
Device view renders in an isolated frame so real responsive breakpoints apply. Switch to Full for overflowing popovers.
Installation
php artisan ui:add form
Registry contract
Install confidence
php artisan ui:add form
writes only the generated targets below. The CLI validates each file hash before writing and
prompts before replacing local changes unless --force is used.
- Version
- 1.0.1
- License
- open
- Stability
- stable
- Contract
- v2
- Foundation
- ≥ 1.0.0
| Type | Generated target |
|---|---|
| blade | resources/views/components/ui/form/form.blade.php |
Registry dependencies
Package dependencies
composer: jml/brok:^1.0
Guidance
Form structure and labelingCollect and organize related user input.
Use when
- Use to collect, group, and clearly label related input so users understand what is being asked and can recover from errors. Do not create dense unlabeled forms; start from one thing per page or one conceptual question per step when the task is unfamiliar or high stakes.
- Submitting user input through Laravel routes with CSRF protection.
- A form needs method spoofing, file-upload encoding, or a validation summary.
Avoid when
- Ask only for information the task needs. Start with one thing per page for unfamiliar or complex flows, and merge questions only when research supports it.
- The markup is not a submission boundary; use a structural container instead.
- Nested inside another form, which is invalid HTML.
- Task length
- medium
- Interaction cost
- medium
- Interruptiveness
- none
- Input precision
- constrained
- Mobile / touch risk
- medium
- Accessibility risk
- high
- Needs background context
- No
- Comparison needed
- No
Preferred alternatives
- Focused question pages
- A smaller set of directly labeled fields
Anti-patterns
- Dense unlabeled forms
- Collecting information without a task need
Anatomy
form root
validation summary
default slot
actions
Theming hooks
validation summary
form spacing
Canonical examples
defaultvalidationfile-upload
API
manifest knowledge + registry-derived coverageProps
| Prop | Type / values | Default | Description |
|---|---|---|---|
| method | GET|POST|PUT|PATCH|DELETE | POST | HTTP method; non-GET/POST verbs use Laravel method spoofing. |
| action | string|null | null | Submission URL. |
| files | bool | false | Enables multipart/form-data encoding. |
| errorSummary | bool | false | Renders the shared validation errors above the fields. |
| hasFiles | bool | false | Declared by @props in the registry Blade source. |
| summary | mixed|null | null | Declared by @props in the registry Blade source. |
Slots
default— Fields, groups, and form actions.x-ui.form.form— Installed subcomponent from the registry item.
Data slots
form
form-error-summary
Capabilities
Behavior
- Emits CSRF protection for state-changing methods and Laravel's hidden _method field when required.
- Declares registry capability flags: a11y, responsive, rtl, darkMode, localized.
Usage
<x-ui.form action="#" method="POST" class="mx-auto w-full max-w-md">
<x-ui.field name="full_name" label="Name">
<x-ui.input name="full_name" placeholder="Ada Lovelace" />
</x-ui.field>
<x-ui.field name="email" label="Email">
<x-ui.input name="email" type="email" placeholder="ada@example.com" />
</x-ui.field>
<x-ui.button type="submit">Save changes</x-ui.button>
</x-ui.form>
Accessibility & localization
data-slot
Keyboard focus-visible
Localized labels
- Keep one clear submit action and move focus to invalid fields or the error summary after failure.
- Uses semantic HTML and a stable
data-slotattribute for styling/scripting hooks. - Focus-visible rings use the
ringtoken so keyboard focus is always visible. - Disabled and invalid states are conveyed to assistive tech, not by color alone.
- Targets WCAG 2.2 AA; verify contrast in light, dark, admin and customer surfaces above.
- Labels go through
__()and the component uses logical properties (ms-*,text-start,start-*) so it mirrors correctly — flip the preview to RTL to confirm.
Source
The exact, editable file ui:add writes
into your app — copy it or own the whole thing. Previews
render this same code; there are no preview-only components.
Changelog
Current version: v1.0.1. See the site changelog for the full release history.