Form Components

Select

Cyber Week Mega Offer!

Huge discounts on all Hostinger plans

Use our referral link for an extra 20% off!

# Basic usage

@php
$users = App\Models\User::pluck('name', 'id');
@endphp
 
<x-select label="Users" wire:model="user_id" :options="$users" />

# Custom placeholder

@php
$countries = collect([
['id' => 1, 'name' => 'BD'],
['id' => 2, 'name' => 'USA'],
['id' => 3, 'name' => 'UK'],
['id' => 4, 'name' => 'RA'],
['id' => 5, 'name' => 'IN']
])->pluck('name', 'id');
@endphp
 
<x-select
label="Countries"
wire:model="country_id"
:options="$countries"
placeholder="Select country"
/>

# Custom slot

@php
$users = App\Models\User::pluck('name', 'id');
@endphp
 
<x-select label="Select user">
<option value="">Choose user</option>
 
@foreach ($users as $key => $name)
<option value="{{ $key }}"> {{ $name }} </option>
@endforeach
</x-select>

# With hint

Only one user can be select

@php
$users = App\Models\User::pluck('name', 'id');
@endphp
 
<x-select label="Users" wire:model="user_id" :options="$users" hint="Only one user can be select" />
Code highlighting powered by Torchlight