Download the PHP package williamug/searchable-select without Composer

On this page you can find all versions of the php package williamug/searchable-select. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package searchable-select

Livewire Searchable Select

Latest Version on Packagist run-tests GitHub Code Style Action Status Total Downloads License

A powerful, feature-rich searchable dropdown component for Laravel Livewire 3 & 4 applications. Built with Alpine.js and styled with Tailwind CSS.

Table of Contents

Features

Screenshots

Requirements

Installation

Install the package via Composer:

The package will automatically register its service provider. You're ready to use it immediately!

You can publish the view files if you need to customize the component HTML:

Tailwind CSS Setup

The component is styled with Tailwind utility classes. You must tell Tailwind to scan the package's blade views, otherwise those classes will be purged and the dropdown will appear unstyled or invisible.

Tailwind v4 (@tailwindcss/vite or @tailwindcss/postcss)

Add a @source directive to your main CSS file (typically resources/css/app.css):

Then rebuild your assets:

Tailwind v3 (tailwindcss with tailwind.config.js)

Add the package views to the content array in tailwind.config.js:

Then rebuild your assets:

That's it! The component will use Tailwind classes and support dark mode automatically.

Quick Start

Basic Usage

Step 1: Create a Livewire Component

Step 2: Set up your component class

Step 3: Use the component in your Blade view

That's it! You now have a fully functional searchable dropdown. The component automatically syncs with your Livewire property via wire:model — no extra :selected-value prop needed.

Component Props Reference

Comprehensive list of all available props:

Prop Type Default Required Description
options Array/Collection [] Yes The list of options to display in the dropdown
placeholder String 'Select option' No Placeholder text shown when nothing is selected
searchPlaceholder String 'Search...' No Placeholder for the search input field
disabled Boolean false No Whether the dropdown is disabled
emptyMessage String 'No options available' No Message shown when the options array is empty
optionValue String 'id' No The key/property to use as the option value
optionLabel String 'name' No The key/property to use as the option display label
multiple Boolean false No Enable multi-select mode (allows selecting multiple options)
clearable Boolean true No Show/hide the clear button
grouped Boolean false No Enable grouped/categorized options mode
groupLabel String 'label' No Key for group labels (when grouped is true)
groupOptions String 'options' No Key for group options array (when grouped is true)

wire:model is a standard Livewire directive, not a declared prop. Pass it as wire:model="propertyName" and the component handles two-way binding automatically.

Props Explanation

Core Props

Labeling Props

Data Mapping Props

Example:

Feature Flags

Usage Examples

Basic Single Select

The most common use case - a simple searchable dropdown:

Multi-Select

Select multiple options with visual tags/badges:

Selected items show as blue badges with × remove buttons.

Dependent/Cascading Dropdowns

Create related dropdowns where child options depend on parent selections (e.g., Country → Region → City):

Key points:

Grouped Options

Organize options into labeled categories:

Custom group keys:

If your data structure uses different keys:

Custom Keys

When your data uses different property names:

With Validation

Integrate with Laravel's validation:

Real-time validation:

Disabled State

Conditionally disable the dropdown:

Without Clear Button

Hide the clear (×) button:

Using Arrays Instead of Models

You don't need Eloquent models - plain arrays work too:

Advanced Features

Custom Styling with CSS Classes

Add custom classes to the component wrapper:

Creating Specialized Components

Build reusable components for common patterns:

resources/views/components/country-select.blade.php:

Usage:

Server-Side Search (Large Datasets)

For thousands of records, implement server-side search:

Customization Guide

Publishing Views

If you need to customize the component HTML, publish the view file:

This copies the view to resources/views/vendor/searchable-select/searchable-select.blade.php. Laravel will use your copy instead of the package default.

Dark Mode Support

The component automatically supports dark mode via Tailwind's dark: classes:

Customizing Search Behavior

The component uses client-side filtering by default. To customize:

  1. Case sensitivity: Modify the Alpine.js searchTerm filtering logic in the published view
  2. Search multiple fields: Adjust the filter to check multiple properties
  3. Server-side search: Use the updatedSearchTerm Livewire pattern shown in Advanced Features

Troubleshooting

Common Issues and Solutions

Dropdown doesn't open / Click doesn't work

Causes:

Solutions:

  1. Verify Alpine.js is loaded (it comes with Livewire 3+):

  2. Check browser console for JavaScript errors (F12 → Console)

  3. Ensure you're not loading Alpine.js separately if using Livewire 3+:

  4. Try clearing browser cache and hard refresh (Ctrl+Shift+R / Cmd+Shift+R)

Selected value not displaying

Causes:

Solutions:

  1. Verify the selected value exists in your options:

  2. Check optionValue matches your data structure:

  3. Use browser DevTools to inspect the component's Alpine.js data

Styling issues / dropdown appears unstyled or invisible

Causes:

Solutions:

  1. Add the package views to Tailwind's scan paths and rebuild:

    Tailwind v4 — add a @source line to resources/css/app.css:

    Tailwind v3 — add to the content array in tailwind.config.js:

  2. Rebuild Tailwind CSS:

  3. Clear Laravel view cache:

  4. Check that your CSS is loading in browser DevTools (Network tab)

Options not updating / Stale data

Causes:

Solutions:

  1. Use wire:key when rendering multiple components in loops:

  2. Every selection calls $wire.set() immediately. Ensure your Livewire component has a matching updated{PropertyName}() method if you need to react to the change server-side.

Multi-select not working

Causes:

Solutions:

  1. Initialize property as array:

  2. Enable multiple mode:

Validation errors not showing

Causes:

Solutions:

  1. Add error display:

  2. Verify property name matches:

Performance issues with large datasets

Causes:

Solutions:

  1. Use Livewire server-side search for large datasets:

  2. Select only needed columns:

Performance Optimization

Dataset Size Guidelines

Options Count Recommended Approach
< 100 Client-side filtering (default) - works perfectly
100 - 1,000 Client-side filtering with wire:key - still performant
1,000+ Server-side search with Livewire updated* hooks

Optimization Techniques

1. Server-Side Search:

2. Caching Options:

3. Select Only Needed Columns:

Testing

The package includes a comprehensive test suite covering all features.

Running Tests

Test Coverage

The package tests include:

17 tests, 33 assertions - all passing

Demo Application

The package includes a full-featured demo application showcasing all features.

Running the Demo

Visit http://localhost:8000

Note: The demo's composer.json references the local package via a VCS repository pointing to ../. No Packagist fetch needed — it installs directly from the local source.

Demo Features

The demo is a single consolidated page at / showcasing:

Demo Source Code

Check the demo Livewire component in demo/app/Livewire/DemoPage.php for implementation examples.

Frequently Asked Questions

How do I implement country → state → city dropdowns?

See the Dependent/Cascading Dropdowns section for a complete example.

Can I customize the component HTML?

Yes! Publish the view file and edit your copy:

Your copy lands in resources/views/vendor/searchable-select/searchable-select.blade.php.

Does it work with Livewire 3 and 4?

Yes, fully compatible with both Livewire 3.x and 4.x.

How do I search across multiple fields?

Use a Livewire server-side search with a custom query:

Can I pre-select multiple values?

Yes, initialize your property as an array:

Does it support dark mode?

Yes, the component automatically supports dark mode using Tailwind's dark: classes.

How do I disable specific options?

This feature is not built-in, but you can publish the view and add a disabled property check in the options loop.

Can I use it with Inertia.js?

The component is designed for Livewire. For Inertia.js, consider using a Vue/React select component instead.

How do I add icons to options?

Publish the view and customize the option rendering to include icons:

Contributing

We welcome contributions! Here's how to get started:

Development Setup

  1. Fork the repository

  2. Install dependencies

  3. Run tests

Contribution Workflow

  1. Create a feature branch

  2. Make your changes

    • Add tests for new features
    • Update documentation if needed
    • Follow PSR-12 coding standards
  3. Run tests and code style checks

  4. Commit your changes

  5. Push to your fork

  6. Open a Pull Request
    • Describe what your PR does
    • Reference any related issues
    • Ensure all tests pass

Code Style

The project uses:

Run before committing:

Reporting Bugs

Found a bug? Please open an issue with:

Suggesting Features

Have an idea? Open a feature request describing:

Changelog

Please see CHANGELOG for recent changes.

Security

If you discover any security vulnerabilities, please email the maintainer instead of using the issue tracker.

Credits

Author

Built With

Inspiration

Inspired by the need for a simple, searchable select component for Laravel Livewire applications.

License

The MIT License (MIT). Please see License File for more information.

Support the Project

If this package saved you time and effort:

Your support helps maintain and improve this package!

Links


**Made with ❤️ for the Laravel community** If this package helped you, please ⭐ star the repository! [Report Bug](https://github.com/williamug/searchable-select/issues) · [Request Feature](https://github.com/williamug/searchable-select/issues) · [Contribute](https://github.com/williamug/searchable-select/pulls)

All versions of searchable-select with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/contracts Version ^11.0||^12.0||^13.0
livewire/livewire Version ^3.0||^4.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package williamug/searchable-select contains the following files

Loading the files please wait ...