EN
Getting started
58 · Forms

Search form

A search box: a magnifying glass icon, a clear button that appears as you type, a keyboard shortcut and an optional attached Search button. Used as a GET form that reloads the page or as a live search with Livewire.

acun:search
02

Search form that reloads the page

When action is given, the component becomes a <form role="search">: Enter or the Search button added with button sends the search text to that URL with GET; the text stays in the URL as ?q= and the link can be shared. To keep other query parameters, write hidden fields inside the component; they are placed inside the form.

LIVE EXAMPLE
<acun:search name="q" :value="request('q')" :action="route('customers.index')" button="Search" placeholder="Search customers">
    <input type="hidden" name="status" value="{{ request('status') }}">
</acun:search>
PropValues
actionURL the form is submitted to
methodGET (default) or POST; @csrf is added for POST
buttonText of the attached submit button
03

Keyboard shortcut

Pressing the shortcut key anywhere on the page focuses the field; it does not fire while typing in another field or when pressed with Ctrl/⌘. While the field is empty and not focused, a hint for the key appears on the right.

LIVE EXAMPLE
<acun:search name="q" shortcut="/" placeholder="Search the menu" />
PropValues
shortcutKey that focuses the field, for example "/"
04

Large size

size="lg" gives a larger, 48-pixel-high field for a page's main search (for example, a help center).

LIVE EXAMPLE
<acun:search name="question" size="lg" button="Search" placeholder="E.g. return policy, downloading invoices" />
PropValues
sizemd (40 px, default) or lg (48 px)
05

Live search with Livewire

With wire:model.live, results arrive as you type; while a request is running, a spinner replaces the magnifying glass (only for requests of this property). If the server changes the value (for example, with a "Clear" button), the clear button and the shortcut hint update on their own.

BLADE
<acun:search wire:model.live.debounce.300ms="search" shortcut="/" placeholder="Search customers" />
PropValues
wire:modelThe bound Livewire property; the field's id also comes from it
06

Search form with filters

When you use it inside a form with other fields, do not give action (forms cannot be nested) and use the form's own submit button. label puts a visible label above the field.

LIVE EXAMPLE
<form wire:submit="search" class="grid items-end gap-4 md:grid-cols-[minmax(0,2fr)_minmax(0,1fr)_auto]">
    <acun:search wire:model="term" label="Search term" placeholder="Name, phone or address" />
    <acun:select wire:model="status" label="Status" :options="['' => 'All statuses', 'pending' => 'Pending', 'approved' => 'Approved']" />
    <acun:button type="submit">Search</acun:button>
</form>
PropValues
labelVisible label above the field
API

Props and slots

The values the component accepts.

PropDefaultDescription
namenullField name (the query parameter in a GET form)
placeholderSearchPlaceholder; without a visible label, the field's accessible name
labelnullVisible label above the field
actionnullIf given, the component becomes a <form role="search">; otherwise a <div role="search">
methodGETGET or POST (@csrf is added for POST)
buttonnullText of the attached submit button
shortcutnullKey that focuses the field, for example "/"
clearabletrueClear (×) button and clearing with Esc
sizemdmd (40 px) or lg (48 px)
class—Added to the outer box; other attributes go to the field
Slots: The default slot is written inside the form, below the field: for hidden fields that keep other query parameters.
Acun UI · Search formDetailed usage and examples