v0.0.2
Demos (demo panel, opens in a new tab)

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 and suffix: view
BLADE

prefix adds text to the left of the field and suffix to the right; the add-on is not part of the submitted value.

blade
<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>
PropValues
prefixText on the left
suffixText on the right

With icons

With icons: view
BLADE

Use the before and after slots for an icon or other content; a slot replaces the prefix / suffix on the same side.

blade
<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>
PropValues
beforeCustom content on the left (slot)
afterCustom content on the right (slot)

Label, hint and required field

Label, hint and required field: view
BLADE

label shows above the field and hint below it; required adds a red star to the label.

blade
<zb:input-group name="fee" label="Monthly subscription fee" suffix="₺" required hint="Per-user monthly price, excluding VAT." />
PropValues
labelLabel above
hintHelp text below
requiredAdds * to the label

Validation error

Validation error: view
BLADE

When the field (name or wire:model) has a validation error, the border turns red and the message replaces the hint.

blade
<zb:input-group name="weight" label="Package weight" suffix="kg" value="-3" hint="Shipping cost is calculated from this weight." />
PropValues
nameThe error is looked up by this name; otherwise wire:model is used

With Livewire

BLADE

With wire:model the field name comes from the property; use .live.blur to validate on the server when the user leaves the field.

blade
<zb:input-group wire:model.live.blur="phone" label="Phone" prefix="+90" />
PropValues
wire:modelThe bound Livewire property

Props

The values the component takes. What are props and slots?

PropTypeDefaultDescription
label—nullLabel above the field
name—nullField name; otherwise the wire:model value is used
hint—nullHelp text below; replaced by the error when there is one
prefix—nullText add-on on the left
suffix—nullText add-on on the right
type—textInput type; other attributes are added to the input as well
input-class—nullClasses of the <input> itself
disabled · readonlybooleanfalseMuted 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

Events, hooks and details
  • The label, hint and validation error work as in zb:input.
  • Attributes such as type, placeholder, value and disabled go to the inner input; class, style, x-show and wire:key go 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 gets aria-invalid.
  • In Livewire 4 a plain .blur updates the value in the browser only and sends no request.
Zubazar UI · ZubazarDesigned for people.