Input group
Adds a fixed part to the left or right of a text field: a country code, a currency, a unit or an icon.
zb:input-group zubazar/ui · free (MIT)
Prefix and suffix
prefix adds text to the left of the field and suffix to the right; the add-on is not part of the submitted value.
<div class="space-y-4">
<zb:input-group name="phone" label="Phone" prefix="+90" placeholder="5xx xxx xx xx" />
<zb:input-group name="price" label="Product price" suffix="₺" placeholder="0.00" inputmode="decimal" />
<zb:input-group name="site" label="Website" prefix="https://" suffix=".com" />
</div>
| Prop | Values |
|---|---|
prefix | Text on the left |
suffix | Text on the right |
With icons
Use the before and after slots for an icon or other content; a slot replaces the prefix / suffix on the same side.
<div class="space-y-4">
<zb:input-group name="email" type="email" label="Email" placeholder="name@company.com">
<zb:slot:before><zb:icon name="envelope" size="4" /></zb:slot:before>
</zb:input-group>
<zb:input-group name="search" type="search" label="Search customers" placeholder="Name, email or phone">
<zb:slot:after><zb:icon name="magnifying-glass" size="4" /></zb:slot:after>
</zb:input-group>
</div>
| Prop | Values |
|---|---|
before | Custom content on the left (slot) |
after | Custom content on the right (slot) |
Label, hint and required field
label shows above the field and hint below it; required adds a red star to the label.
<zb:input-group name="fee" label="Monthly subscription fee" suffix="₺" required hint="Per-user monthly price, excluding VAT." />
| Prop | Values |
|---|---|
label | Label above |
hint | Help text below |
required | Adds * to the label |
Validation error
When the field (name or wire:model) has a validation error, the border turns red and the message replaces the hint.
<zb:input-group name="weight" label="Package weight" suffix="kg" value="-3" hint="Shipping cost is calculated from this weight." />
| Prop | Values |
|---|---|
name | The error is looked up by this name; otherwise wire:model is used |
With Livewire
With wire:model the field name comes from the property; use .live.blur to validate on the server when the user leaves the field.
<zb:input-group wire:model.live.blur="phone" label="Phone" prefix="+90" />
| Prop | Values |
|---|---|
wire:model | The bound Livewire property |
Props
The values the component takes. What are props and slots?
| Prop | Type | Default | Description |
|---|---|---|---|
label | — | null | Label above the field |
name | — | null | Field name; otherwise the wire:model value is used |
hint | — | null | Help text below; replaced by the error when there is one |
prefix | — | null | Text add-on on the left |
suffix | — | null | Text add-on on the right |
type | — | text | Input type; other attributes are added to the input as well |
input-class | — | null | Classes of the <input> itself |
disabled · readonly | boolean | false | Muted background like zb:input; the box fits narrow columns |
Slots: before, after: an icon or custom content; when given, shown instead of prefix / suffix.
Developer notes
- The label, hint and validation error work as in
zb:input. - Attributes such as
type,placeholder,valueanddisabledgo to the innerinput;class,style,x-showandwire:keygo to the element around the whole field. - The hint and the error are linked to the field with
aria-describedby; with an error the field getsaria-invalid. - In Livewire 4 a plain
.blurupdates the value in the browser only and sends no request.