Skip to main content
Copy for LLM

Form

<x-wirekit::form> is a real <form> element that also carries one setting governing how every control inside announces its validation errors to screen readers, and can hold a second press back until the page changes. Drop your wire:submit, action, and method onto it exactly as you would a native form.

A form with stacked fields

Saying What the Asterisk Means

A required field shows an asterisk after its label. A reader who sees it is told what it means before the first field that carries it, as WCAG technique H90 asks: required-note puts the sentence at the start of the form.

A form that says what its asterisk means

Required fields are marked with an asterisk .

The sentence is in the application's language, with the asterisk drawn in the color of the label's. A screen reader hears the words "an asterisk" and not the symbol, since a field already says it is required through aria-required. To turn it on for every form, set the default in config/wirekit.php, and a form can still pass :required-note="false":

// config/wirekit.php
'components' => [
    'form' => ['required-note' => true],
],

A form you write as a plain <form> places the sentence itself, before its first field:

<form wire:submit="save">
    <x-wirekit::form.required-note />
    <x-wirekit::input name="email" type="email" label="Email" required />
</form>

A Form Without Asterisks

A form in which every field is required needs no mark: there is nothing the reader may leave out. :required-mark="false" leaves the asterisk out of every required field inside and keeps each one required, so the browser still checks it and a screen reader still hears it:

<x-wirekit::form wire:submit="confirm" :required-mark="false">
    <x-wirekit::password-input name="passphrase" label="Passphrase" required />
    <x-wirekit::otp-input name="code" label="Code" required />
    <x-wirekit::button type="submit">Confirm</x-wirekit::button>
</x-wirekit::form>

The sentence of required-note goes with the mark it explains, so such a form shows neither. An input, a password input and an OTP input take requiredMark themselves as well, which decides for that field alone, in a form that keeps the mark or in one that leaves it out.

Fields Outside the Form

A field that stands outside the form, in a table row or a sidebar, joins it with form and the form's id, the way a native field does. Every form component hands the attribute to the field it submits, so its value arrives with the form, a hidden field included.

A rating that joins a form from outside it

Resetting the Form

A reset button, or form.reset() from your own script, returns every form component to the value it was rendered with, as it returns a native field to its value. That includes a component that keeps its value in a hidden field, which sends and shows its starting value again, and one that joins the form from outside it through form. A reset that a listener cancels with preventDefault() leaves every component as it was, as it leaves a native field.

Change the score or the view, then undo both

Sending a Form Once

A form that Livewire does not send is an ordinary submission: the browser sends it and shows the page that answers. A second press before that page arrives sends the form again, and the browser shows the answer to the second request. Where the server takes a request only once, the second request undoes the first. A code that is good for one sign-in is spent by the first request and refused in the second, and a mail whose link the next mail replaces arrives twice, the first link already dead.

submit-once lets the first submission go and holds every further one back until the page changes:

<x-wirekit::form method="POST" action="/verify" submit-once>
    @csrf
    <x-wirekit::input name="code" label="Code from the mail" />
    <x-wirekit::button type="submit">Confirm</x-wirekit::button>
</x-wirekit::form>

While the page changes, the form and the button that sent it carry aria-busy="true". The button is not disabled: a disabled button hands the focus to the page, and a keyboard user would have to find their place again.

The form takes a submission again in two cases. When the reader goes back and the browser shows the page from its back-forward cache, it is the page before the submission. And when the answer leaves the page as it is, a download for example, it waits submit-once-release milliseconds, ten seconds unless the form names its own. 0 waits for the page alone:

<x-wirekit::form method="POST" action="/invoices/export" submit-once :submit-once-release="3000">
    @csrf
    <x-wirekit::button type="submit">Download the invoices</x-wirekit::button>
</x-wirekit::form>

A plain <form> asks the same with data-wk-submit-once, and names its wait with data-wk-submit-once-release:

<form method="POST" action="/password/email" data-wk-submit-once>
    @csrf
    <x-wirekit::input name="email" type="email" label="Email" />
    <x-wirekit::button type="submit">Send the reset link</x-wirekit::button>
</form>

A form that Livewire sends with wire:submit has a loading state of its own, and the script leaves a submission that another script has taken over alone. So it does with a form that closes a dialog (method="dialog"), which sends nothing. Without the script, the form is an ordinary form.

Focus and Blur on a Control of Several Parts

x-on:focus, x-on:blur and wire:blur on a form component run when the reader enters and leaves the control, as they run on a native field. A component made of several parts, such as a tags input, a one-time code, a rating or a date picker with range, fires them once for the whole: moving between its own parts fires nothing, and neither does moving into a panel it opened elsewhere on the page, such as the list of a multi-select. A press counts like focus, so a star chosen with the pointer in Safari, which does not focus a button on a click, is left when the reader presses somewhere else.

Count how often the reader leaves the rating

Times the rating was left:

Neither event bubbles, as a field's do not. A listener on an element around the component hears focusin and focusout instead, once for each part, as the browser sends them.

The Focus After a Refused Save

When the server refuses a save, the focus stays on the button the reader pressed, and the fields that need them can be anywhere on the page, further down or folded away in a card. Dispatch wirekit:focus-invalid with the refusal, and the focus goes to the first field of the page that carries aria-invalid="true", which every WireKit field sets on its error.

The component validates, and dispatches the event before it lets the refusal go on:

<?php

namespace App\Livewire;

use Illuminate\Validation\ValidationException;
use Livewire\Attributes\Validate;
use Livewire\Component;

class ShippingSettings extends Component
{
    #[Validate('required')]
    public string $returnAddress = '';

    public function save(): void
    {
        try {
            // 1. Check every rule before anything is stored.
            $this->validate();
        } catch (ValidationException $exception) {
            // 2. Take the reader to the first field the rules refused.
            $this->dispatch('wirekit:focus-invalid');

            // 3. Let Livewire show the messages as it always does.
            throw $exception;
        }

        // 4. Store the settings here.
    }
}

The view puts the field in a card that stays closed until something in it needs the reader:

<x-wirekit::form id="shipping-settings" wire:submit="save">
    {{-- 1. A card that folds. A refused field inside opens it. --}}
    <x-wirekit::card collapsible heading="Returns">
        <x-wirekit::card.body>
            <x-wirekit::input name="returnAddress" wire:model="returnAddress" label="Return address" />
        </x-wirekit::card.body>
    </x-wirekit::card>

    {{-- 2. The save the server may refuse. --}}
    <x-wirekit::button type="submit">Save</x-wirekit::button>
</x-wirekit::form>

Whatever hides the field opens first: every collapsible card around it, the step of a wizard that holds it, and a panel the browser's find in page could open, such as an accordion item or a collapsible. The focus follows within a few frames, once the field shows. A field that never shows, inside a closed dialog for example, passes the focus on to the next rejected field. A rejected group, a list of radios for example, gives the focus to its first entry. within keeps the search inside one element, named by its id, such as the form above:

// In save(), in place of the dispatch above: search only the shipping settings.
$this->dispatch('wirekit:focus-invalid', within: 'shipping-settings');

The focus moves only when the event asks for it. A field that turns invalid while the reader types in it, under wire:model.live, leaves the focus where the reader is.

Why a form-level setting

Every WireKit form control can announce its error in an aria-live region so a validation message that appears dynamically is read out. That is the right default — but whether you want it is a property of the form, not the app:

  • A form that renders its own error summary — a role="alert" list that announces every message and pulls focus (the standard WCAG 3.3.1 pattern) — should turn the per-field live regions off, or every error is announced twice.
  • A form with no summary needs them on, or a dynamically-appearing error is never announced at all.

The global wirekit.a11y.announce_error config can only pick one for the whole app. <x-wirekit::form> scopes the choice to a single form:

{{-- This form renders its own summary, so silence the per-field live regions. --}}
<x-wirekit::form :announce-errors="false" wire:submit="login">
    {{-- your own <div role="alert"> summary here --}}
    <x-wirekit::input name="email" label="Email" />
    <x-wirekit::input name="password" type="password" label="Password" />
</x-wirekit::form>

Precedence

An explicit :announce-error on a single control always wins, so you can opt one control back in even inside a silenced form:

<x-wirekit::form :announce-errors="false">
    <x-wirekit::input name="email" label="Email" />
    {{-- this one still announces, summary or not --}}
    <x-wirekit::input name="code" label="2FA code" :announce-error="true" />
</x-wirekit::form>

The order, highest priority first:

  1. A per-control :announce-error.
  2. The surrounding <x-wirekit::form :announce-errors="…">.
  3. The global wirekit.a11y.announce_error config (default true).

A <x-wirekit::field.set> follows the same order for its group error: its own :announce-error, then the form, then the config.

Props

Prop Type Default Description
announceErrors bool|null null false silences every control's aria-live error region inside this form; true forces it on; null inherits the global config.
submitOnce bool false Holds every submission after the first back until the page changes, so a second press sends nothing. For a form Livewire does not send; see Sending a Form Once.
submitOnceRelease int 10000 Milliseconds a held form waits for the page to change before it takes a submission again, for an answer that leaves the page as it is. 0 waits for the page alone.
requiredNote bool false Says at the start of the form what the asterisk of a required field means; see Saying What the Asterisk Means. required-note in the form entry of the configuration sets it for every form.
requiredMark bool true false leaves the asterisk out of every required field inside and keeps each one required; the requiredNote sentence goes with it. See A Form Without Asterisks.
scope string|null null Class-scope override for the <form> element.

All other attributes (wire:submit, action, method, class, …) pass through to the underlying <form>.

<x-wirekit::form.required-note>

Prop Type Default Description
scope string|null null Class-scope override for the sentence.

The sentence that requiredNote puts at the start of a form, for a form written as a plain <form>. Other attributes pass through to its <p>.

Accessibility

  • When announce-errors is false, provide your own announcement — a role="alert" error summary is the usual choice, and it should receive focus when submission fails so the reader is taken straight to it.
  • When announce-errors is left true/null, each control announces its own error in a polite live region; do not also render a summary, or the reader hears every message twice.
  • A form with submit-once holds a second press back without disabling the button: the focus stays where the reader pressed, and aria-busy="true" on the form and the button says that the form is on its way.

Keyboard Interaction

The wrapper is a native <form> and adds no keyboard behavior of its own — the controls inside keep theirs, and Enter in a text field submits the form exactly as the browser does natively.

Updated in WireKit v2.74.0 (2026-11-24)

Was this page helpful?

Thank you for your feedback!

Voting requires cookies or local storage. What we store