Text input
A labeled text input that shows its validation error by itself.
zb:input zubazar/ui · free (MIT)
Basic usage
label draws a label above the field; the field's name and id come from the wire:model value.
<div class="space-y-4">
<zb:input wire:model="product_name" label="Product name" placeholder="E.g. Wireless headphones" />
<zb:input name="custom_code" label="Custom code" value="SKU-01" />
</div>
| Prop | Values |
|---|---|
label | Label above the field |
name | Field name; defaults to the wire:model value |
Label and hint
hint adds a short help text below the field, and required puts a red asterisk next to the label.
<div class="space-y-4">
<zb:input wire:model="phone" type="tel" label="Phone" required hint="10 digits, without the leading 0." />
<zb:input wire:model="custom_code" label="Custom code" hint="Shown as the short name in reports." />
</div>
| Prop | Values |
|---|---|
hint | Help text below |
required | Attribute; adds * to the label |
Types
type goes straight to the field (default text); type="search" puts a magnifier on its left.
<div class="space-y-4">
<zb:input name="email" type="email" label="Email" placeholder="name@example.org" />
<zb:input name="stock_quantity" type="number" label="Stock quantity" min="0" value="12" />
<zb:input name="delivery_date" type="date" label="Delivery date" />
<zb:search wire:model.live.debounce.400ms="search" placeholder="Product name or custom code" aria-label="Search products" />
</div>
| Prop | Values |
|---|---|
type | text | email | number | date | tel | search | password … |
Password field
With type="password" and viewable, an eye button on the right of the field shows and hides the password.
<div class="space-y-4">
<zb:input wire:model="password" type="password" label="Password" viewable />
<zb:input wire:model="password_confirmation" type="password" variant="floating" label="Password (again)" viewable />
</div>
| Prop | Values |
|---|---|
viewable | true | false |
Validation error
If $errors has an error for the field's name, the border turns red and the message shows below the field, in place of the hint.
<zb:input wire:model="national_id" label="National ID no." value="1234567" hint="11-digit number." />
| Prop | Values |
|---|---|
aria-describedby | Attribute; the message id is appended to the given value |
Props
The values the component takes. What are props and slots?
| Prop | Type | Default | Description |
|---|---|---|---|
label | — | null | Label; * is added next to it when the required attribute is present |
name | — | null | Field name; defaults to the wire:model value. The id and the error key also come from it |
hint | — | null | Help text below while there is no error; linked to the field with aria-describedby |
variant | — | default | default · floating |
viewable | boolean | false | Show/hide button on password fields, also usable with the keyboard (aria-pressed) |
input-class | — | null | Classes of the <input> element itself; class places the whole field |
(attributes) | — | — | class, style, :class, x-show, x-cloak, wire:key, wire:show, x-transition… go on the outer element that wraps the whole field; type, placeholder, value, name, wire:model, required, disabled, readonly, id, aria-*, data-* and events go straight to the <input> element. aria-describedby is merged with the message id |
Advanced
Floating label
variant="floating" puts the label inside the field; when the field is focused or filled, the label shrinks up to the top edge. Since the label does the placeholder's job, don't use placeholder; it suits forms with few fields, such as a login screen.
<div class="space-y-4">
<zb:input wire:model="email" type="email" variant="floating" label="Email" />
<zb:input name="full_name" variant="floating" label="Full name" value="Ayşe Yılmaz" />
</div>
| Prop | Values |
|---|---|
variant | default | floating |
Disabled and read-only
disabled draws the field gray and its value is not submitted; readonly only gives a gray background, and the value is still submitted and can be copied. On a floating-label field the disabled state is shown faded so the label notch is not broken.
<div class="space-y-4">
<zb:input name="customer_no" label="Customer no." value="CUS-10482" readonly />
<zb:input name="registration_date" label="Registration date" value="12.03.2026" disabled />
<zb:input name="company" variant="floating" label="Company" value="Acme Software" disabled />
</div>
| Prop | Values |
|---|---|
disabled | Attribute; gray background and text (faded with a floating label) |
readonly | Attribute; gray background (except with a floating label) |
Developer notes
nameandidare derived with modifiers such aswire:model.livetoo; since the id stays the same on every update, focus is not lost during Livewire updates. Without Livewire, passname.- Attributes such as
placeholderandvaluego straight to the<input>, whileclass,style,x-showandwire:keygo on the outer element that wraps the whole field; to style the<input>itself, passinput-class. - The hint gives way to the error message when there is one;
requiredalso turns on the browser's required-field check. - The eye button works with the floating label too.
- The message id is built by appending
-messageto the field id (herenational_id-message); your ownaria-describedbyvalue is kept and the message id is added next to it. - In Livewire the error display works by itself after
$this->validate(); no extra code is needed.
Accessibility
- Label
labelrenders a<label for>tied to the inputid. Without anid, one is built from the name or thewire:modelproperty; the same name a second time on the page gets-2. The floating variant links its label the same way.- Hint and error
- The
hintor the validation error under the field is linked witharia-describedby. Your ownaria-describedbyis kept and the two are merged. With an error the input getsaria-invalid="true". - Required
- The red asterisk is hidden from screen readers (
aria-hidden). Therequiredattribute, which goes straight to the<input>, announces it. - Show password
viewableadds a "Show password" button. It is in the tab order, andaria-pressedtells whether the password is visible.- What you provide
- Give a field without
label(a search box, for example) anaria-label; it goes on the<input>. The error text is not a live region (norole="alert"), so it is read when the field is focused.