Download the PHP package ajjitech/searchable-select without Composer

On this page you can find all versions of the php package ajjitech/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 supports both Tailwind CSS and Bootstrap 5 out of the box!

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 configuration file:

CSS Framework Setup

Tailwind CSS (Default)

The component uses Tailwind CSS by default. No additional configuration needed!

1. Ensure Tailwind is installed in your project:

2. Add the package views to your tailwind.config.js:

3. Build your CSS:

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

Bootstrap 5

To use Bootstrap 5 instead of Tailwind:

1. Publish the configuration file:

This creates config/searchable-select.php.

2. Set the theme to Bootstrap:

Edit config/searchable-select.php:

Or use environment variable (recommended):

Add to your .env file:

3. Include Bootstrap assets in your layout if you haven't already:

Add to your resources/views/layouts/app.blade.php (or wherever your layout is):

Note: The component's dropdown functionality uses Alpine.js (included with Livewire), so Bootstrap's JavaScript is optional unless you're using other Bootstrap components.

Switching Themes

Global Theme Switch

Change the theme application-wide by updating config/searchable-select.php:

Or via environment variable:

Per-Component Theme Override

You can override the theme for individual components using the theme prop:

This allows you to:

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.

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
wireModel String '' Yes The Livewire property to bind the selected value to
selectedValue Mixed null No The currently selected value (for reactivity)
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
apiUrl String null No API endpoint URL for fetching options dynamically
apiSearchParam String 'search' No Query parameter name for API search (e.g., ?search=term)
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)
theme String null No Override the CSS framework theme ('tailwind' or 'bootstrap')

Props Explanation

Core Props

Labeling Props

Data Mapping Props

Example:

Feature Flags

API Integration Props

See API/Ajax Integration for full examples.

Theme Props

Usage Examples

Basic Single Select

The most common use case - a simple searchable dropdown:

Multi-Select

Select multiple options with visual tags/badges:

Tailwind styling: Selected items show as blue badges with × remove buttons Bootstrap styling: Selected items show as primary 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:

API/Ajax Integration

Fetch options dynamically from a backend API:

Step 1: Create an API endpoint

Step 2: Use the component with API URL

Multi-select with API:

API Response Format:

Your API should return JSON in this format:

For custom keys, use option-value and option-label:

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:

Tailwind:

Bootstrap:

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:

Or better yet, use the built-in API integration feature shown above.

Mixing Themes in One Application

You can use both Tailwind and Bootstrap in the same app:

Customization Guide

Publishing Views

If you need to customize the component HTML:

This copies the views to resources/views/vendor/searchable-select/:

Now you can modify them as needed. Your custom views will be used instead of the package defaults.

Dark Mode Support (Tailwind)

The Tailwind version automatically supports dark mode:

Bootstrap Dark Mode

For Bootstrap dark mode, you can:

  1. Use Bootstrap's data-bs-theme attribute:

  2. Or publish the Bootstrap view and customize the color classes

Customizing Search Behavior

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

  1. Case sensitivity: Modify the Alpine.js searchTerm filtering logic
  2. Search multiple fields: Adjust the filter to check multiple properties
  3. Server-side search: Use wire-model.live.debounce with API integration

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 (Tailwind)

Causes:

Solutions:

  1. Add package views to tailwind.config.js:

  2. Rebuild Tailwind CSS:

  3. Clear Laravel view cache:

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

Styling issues (Bootstrap)

Causes:

Solutions:

  1. Verify Bootstrap is loaded in your layout:

  2. Confirm theme is set to Bootstrap:

  3. Clear config cache:

  4. Use browser DevTools to inspect if correct classes are applied (should see form-control, dropdown-menu, etc.)

Options not updating / Stale data

Causes:

Solutions:

  1. Always pass :selected-value for reactivity:

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

  3. Use wire-model.live for immediate updates:

API integration not working

Causes:

Solutions:

  1. Verify API endpoint is accessible:

  2. Check API response format (must have data key):

  3. Check browser Network tab (F12) for API requests and responses

  4. For CORS issues, add to config/cors.php:

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 API integration for large datasets:

  2. Implement server-side pagination:

  3. Use debouncing for search:

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 - 10,000 Consider API integration with search - better UX
> 10,000 Must use API integration - client-side will be slow

Optimization Techniques

1. Lazy Loading with API:

2. Server-Side Search:

3. Caching Options:

4. Select Only Needed Columns:

5. Debouncing for Dependent Dropdowns:

Testing

The package includes a comprehensive test suite covering all features.

Running Tests

Test Coverage

The package tests include:

24 tests, 46 assertions - all passing

Demo Application

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

Running the Demo

With Docker:

Visit http://localhost:8000

Without Docker:

Demo Features

The demo includes live examples of:

Demo Source Code

Check the demo Livewire components in demo/app/Livewire/ for implementation examples.

Frequently Asked Questions

Can I use both Tailwind and Bootstrap in the same project?

Yes! You can set different themes per component:

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 views:

Then edit the files in resources/views/vendor/searchable-select/.

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 API integration with a custom endpoint that searches multiple columns:

Can I pre-select multiple values?

Yes, initialize your property as an array:

Does it support dark mode?

Yes, the Tailwind version automatically supports dark mode using dark: classes. For Bootstrap, use Bootstrap 5.3's dark mode features.

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, framework-agnostic 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/ajjitech/searchable-select/issues) · [Request Feature](https://github.com/ajjitech/searchable-select/issues) · [Contribute](https://github.com/ajjitech/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 ajjitech/searchable-select contains the following files

Loading the files please wait ...