Skip to content

How to use Fluxui Select and autocomplete with remote data? #800

Closed Answered by joshhanley
ramabie asked this question in Feature Requests
Discussion options

You must be logged in to vote

@ramabie you'd do it like this

<?php

use App\Models\User;
use Livewire\Attributes\Computed;
use Livewire\Volt\Component;

new class extends Component {
    public $search;
    public $userId;

    #[Computed]
    public function users()
    {
        if (!$this->search) {
            return collect();
        }

        return User::query()
            ->when($this->search, fn($query, $search) => $query->where('name', 'like', "%$search%"))
            ->get();
    }
};

?>

<div class="p-4">
    <flux:select variant="combobox" :filter="false" wire:model.live="userId">
        <x-slot name="input">
            <flux:select.input wire:model.live="search" />
        </x-slot>

        @fore…

Replies: 4 comments 7 replies

Comment options

You must be logged in to vote
2 replies
@ramabie
Comment options

@DanielSpravtsev
Comment options

Comment options

You must be logged in to vote
1 reply
@joshhanley
Comment options

Comment options

You must be logged in to vote
1 reply
@joshhanley
Comment options

Comment options

You must be logged in to vote
3 replies
@joshhanley
Comment options

Answer selected by joshhanley
@ramabie
Comment options

@joshhanley
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants