We are working to upgrade the V2 to TailwindCSS v4

Powerful suite of Blade components for TALL Stack apps.

Select

Select components.

<x-select.native :options="[1,2,3]" />
You can choose 1, 2 or 3
<x-select.native label="Select One Option" hint="You can choose 1, 2 or 3" :options="[1,2,3]" />

An option to use multi-dimensional array.

<x-select.native :options="[
['label' => 'TALL', 'value' => 1],
['label' => 'LIVT', 'value' => 2],
]" />

When the value and label do not come from the label and value positions respectively, you must specify this manually using the select attribute:

<x-select.native :options="[
['name' => 'TALL', 'id' => 1],
['name' => 'LIVT', 'id' => 2],
]" select="label:name|value:id" />
<x-select.native group :options="[
[
'label' => 'Brazil',
'value' => [
['label' => 'São Paulo', 'value' => 4],
['label' => 'Rio de Janeiro', 'value' => 5],
['label' => 'Brasília', 'value' => 6]
]
],
[
'label' => 'United States',
'value' => [
['label' => 'New York', 'value' => 7],
['label' => 'Los Angeles', 'value' => 8],
['label' => 'Chicago', 'value' => 9]
]
],
]" />

This option is also available for the other select components below.

Styled Select

Customized styled select component to interact with Livewire.

<x-select.styled :options="[1,2,3]" />
You can choose 1, 2 or 3
<x-select.styled label="Select One Option"
placeholder="Custom Placeholder"
hint="You can choose 1, 2 or 3"
:options="[1,2,3]" />
<!-- Changing only the placeholder of the input -->
<x-select.styled placeholder="Custom Placeholder" ... />
 
<!-- Changing all placeholders -->
<x-select.styled :placeholders="[
'default' => 'This is the default placeholder',
'search' => 'This is the search placeholder',
'empty' => 'This is the empty placeholder',
]" ... />

An option to make the select component required.

<x-select.styled :options="[1,2,3]" required />

The user will not be able to deselect the selected option after selecting an option.

<x-select.styled :options="[1,2,3,4,5,6]" multiple />

An option to use multi-dimensional array.

<x-select.styled :options="[
['label' => 'TALL', 'value' => 1],
['label' => 'LIVT', 'value' => 2],
]" />

When the value and label do not come from the label and value positions respectively, you must specify this manually using the select attribute:

<x-select.styled :options="[
['name' => 'TALL', 'id' => 1],
['name' => 'LIVT', 'id' => 2],
]" select="label:name|value:id" />

An option to disable specific options.

<x-select.styled :options="[
['label' => 'TALL', 'value' => 1, 'disabled' => true],
['label' => 'LIVT', 'value' => 2],
]" />

An option to limit the number of selections.

<!-- Applicable only when selection is multiple -->
 
<x-select.styled :limit="2" :options="[
['label' => 'TALL', 'value' => 1],
['label' => 'LIVT', 'value' => 2],
['label' => 'Blade', 'value' => 3],
['label' => 'API', 'value' => 4],
]" multiple />

The styled select allows you to display an image next to the option label. To do this, the options simply have an index called image with the image URL.

<x-select.styled :options="[
['label' => 'Taylor Otwell', 'value' => 1, 'image' => 'https://unavatar.io/github/taylorotwell'],
['label' => 'Nuno Maduro', 'value' => 2, 'image' => 'https://unavatar.io/github/nunomaduro'],
['label' => 'Jess Archer', 'value' => 3, 'image' => 'https://unavatar.io/github/jessarcher'],
]" />

You can also set a different index to the image via the select attribute.

<x-select.styled :options="[
['label' => 'Taylor Otwell', 'value' => 1, 'preview' => 'https://unavatar.io/github/taylorotwell'],
['label' => 'Nuno Maduro', 'value' => 2, 'preview' => 'https://unavatar.io/github/nunomaduro'],
['label' => 'Jess Archer', 'value' => 3, 'preview' => 'https://unavatar.io/github/jessarcher'],
]" select="label:label|value:value|image:preview" />

You can also set a description for each option. To do this, the options simply have an index called description .

<x-select.styled :options="[
['label' => 'Taylor Otwell', 'value' => 1, 'description' => 'Taylor Otwell is the creator of Laravel'],
['label' => 'Nuno Maduro', 'value' => 2, 'description' => 'Nuno Maduro is the creator of PestPHP'],
['label' => 'Jess Archer', 'value' => 3, 'description' => 'Jess Archer is the creator of Laravel Prompts'],
]" />

You can also set a different index to the description via the select attribute:

<x-select.styled :options="[
['label' => 'Taylor Otwell', 'value' => 1, 'note' => 'Taylor Otwell is the creator of Laravel'],
['label' => 'Nuno Maduro', 'value' => 2, 'note' => 'Nuno Maduro is the creator of PestPHP'],
['label' => 'Jess Archer', 'value' => 3, 'note' => 'Jess Archer is the creator of Laravel Prompts'],
]" select="label:label|value:value|description:note" />
<x-select.styled :options="[
['label' => 'TALL', 'value' => 1],
['label' => 'LIVT', 'value' => 2],
]" searchable />

Lazy loading is a way to slowly load options as you scroll down the floating element that displays the available options. While this is extremely useful for delaying the loading of large amounts of options, there is two major caveat:

  • The searchable attribute will not work to search for options that have not yet been loaded.
  • The lazy attribute expects to receive values greater than or equal to 10.
<x-select.styled :options="[
['label' => 'PHP', 'value' => 1],
['label' => 'JavaScript', 'value' => 2],
['label' => 'Python', 'value' => 3],
['label' => 'Java', 'value' => 4],
['label' => 'C#', 'value' => 5],
['label' => 'C++', 'value' => 6],
['label' => 'Ruby', 'value' => 7],
['label' => 'Swift', 'value' => 8],
['label' => 'Kotlin', 'value' => 9],
['label' => 'Go', 'value' => 10],
['label' => 'TypeScript', 'value' => 11],
['label' => 'C', 'value' => 12],
['label' => 'Objective-C', 'value' => 13],
['label' => 'R', 'value' => 14],
['label' => 'Perl', 'value' => 15],
['label' => 'Scala', 'value' => 16],
['label' => 'Haskell', 'value' => 17],
['label' => 'Lua', 'value' => 18],
['label' => 'Rust', 'value' => 19],
['label' => 'Dart', 'value' => 20],
['label' => 'Assembly', 'value' => 21],
['label' => 'SQL', 'value' => 22],
['label' => 'NoSQL', 'value' => 23],
['label' => 'HTML', 'value' => 24],
['label' => 'CSS', 'value' => 25],
['label' => 'Bash', 'value' => 26],
['label' => 'PowerShell', 'value' => 27],
['label' => 'Groovy', 'value' => 28],
['label' => 'Visual Basic', 'value' => 29],
['label' => 'Fortran', 'value' => 30],
]" lazy="10" />
<x-select.styled group :options="[
[
'label' => 'Brazil',
'image' => 'https://placehold.co/15x15/cyan/white',
'description' => 'Brazil is a country known for being the land of samba.',
'value' => [
['label' => 'São Paulo', 'value' => 4, 'image' => 'https://placehold.co/15x15/orange/white'],
['label' => 'Rio de Janeiro', 'value' => 5, 'image' => 'https://placehold.co/15x15/orange/white'],
['label' => 'Brasília', 'value' => 6, 'image' => 'https://placehold.co/15x15/orange/white']
]
],
[
'label' => 'United States',
'image' => 'https://placehold.co/15x15/purple/white',
'description' => 'The United States is a country known for being the land of opportunity.',
'value' => [
['label' => 'New York', 'value' => 7, 'image' => 'https://placehold.co/15x15/blue/white'],
['label' => 'Los Angeles', 'value' => 8, 'image' => 'https://placehold.co/15x15/blue/white'],
['label' => 'Chicago', 'value' => 9, 'image' => 'https://placehold.co/15x15/blue/white']
]
],
]" />

An option to interact with the search term when nothing is found.

<x-select.styled searchable :options="[1,2,3]">
<x-slot:after>
<div class="px-2 mb-2 flex justify-center items-center">
<x-button x-on:click="show = false; $dispatch('confirmed', { term: search })">
<span x-html="`Create user <b>${search}</b>`"></span>
</x-button>
</div>
</x-slot:after>
</x-select.styled>
<x-select.styled :options="[
['label' => 'TALL', 'value' => 1],
['label' => 'LIVT', 'value' => 2],
]" x-on:select="alert(`Select: ${JSON.stringify($event.detail.select)}`)"
x-on:remove="alert(`Remove: ${JSON.stringify($event.detail.select)}`)"
multiple />
Styled API Select

The styled select component allows you to query for values via an API. In this mode, all the options available above remain available for use, the difference is that instead of setting the options using the options parameter, you must specify the API URL where the results will come from. For identification purposes, a header called X-Tallstack-Ui will be added to all requests.

<x-select.styled :request="route('api.users')" />

When the value and label do not come from the label and value positions respectively, you must specify this manually using the select attribute, like mentioned in the multi-dimensional array section. This example do not set the select attribute because the API returns the values in the correct format.

The styled select component filters the API results using internal logic to search for the desired option based on the term entered in the input only in the item's label or description . You can disable this behavior to make the filters apply only in the API. In other words, you need to ensure that, for example, the value search applies a where based on the term sent in the search and appended to the query string search .

<x-select.styled :request="route('api.users')" unfiltered />

This is only available in the styled API select.

In this example, the query was builded as follows:

use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use Illuminate\Database\Eloquent\Builder;
 
Route::get('/users', function (Request $request) {
$search = $request->get('search');
 
return User::query()
->when($search, fn (Builder $query) => $query->where('name', 'like', "%{$search}%"))
->unless($search, fn (Builder $query) => $query->limit(10))
->get()
->map(fn (User $user): array => [
'label' => $user->name,
'value' => $user->id,
]);
})->name('api.users');

Which means:

  • When search is set, then the query will be filtered by the name column.
  • When search is not set, then the query will return only 10 results.

Optionally, you can set the unfiltered globally by the TallStackUI configuration file.

You have the possibility to customize some things related to the request, such as the method used: get or post , and also add more params to the request. One of the big advantages of using these advanced options is the params parameter, because it is hydrated. This means that if you are using this component within the Livewire components and create a variable to be used in params , when making any changes to this variable and Livewire hydrates the page, the next time the select is opened to make a new request, params will be updated in the request.

<x-select.styled :request="[
'url' => route('api.users'),
'method' => 'get',
'params' => ['library' => 'TallStackUi'],
]" />

Code highlighting provided by Torchlight