Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Choices Laravel Package

contao-components/choices

Contao Components Choices adds the Choices.js library integration for Contao CMS, enhancing select boxes and input fields with searchable, taggable, and multi-select UI features. Ideal for modern form UX with minimal setup.

View on GitHub
Deep Wiki
Context7

Choices.js integration

Frequently asked questions about Choices
How do I integrate Choices.js into a Laravel project using Laravel Mix?
First, install the package via Composer: `composer require contao-components/choices`. Then, include the Choices.js CSS in your `resources/js/app.js` and import the library. Use the PHP wrapper in Blade templates like this: `{{ Choices::make('select-id')->options($data)->render() }}`. Laravel Mix will bundle the required assets automatically.
Does this package work with Laravel 10 and Vite?
Yes, the package supports Laravel 10 and Vite. Ensure you alias the Choices.js assets in your `vite.config.js` and include the CSS/JS in your entry file. The PHP wrapper remains compatible, but test for any Vite-specific quirks, especially if using SSR frameworks like Inertia.js.
Can I use Choices.js for dynamic data fetching (e.g., API-driven autocomplete)?
Absolutely. The package works with static data, but for dynamic fetching, pair it with Laravel API routes. Use AJAX to load options as the user types, then initialize Choices.js on the frontend. Example: Fetch data from `/api/search?q={query}` and pass it to `Choices::make()->options($dynamicData)->render()`.
Is there a way to customize the styling of Choices.js dropdowns?
Yes, you can override default styles by targeting `.choices` and `.choice` classes in your CSS. For advanced customization, use Choices.js’s built-in templating system or extend the PHP wrapper with custom JavaScript. The package doesn’t restrict styling, but complex templates may require manual JS overrides.
What Laravel versions does contao-components/choices support?
The package is designed for Laravel 8+ and works with Laravel 9/10. It leverages modern PHP (8.0+) features and integrates with Laravel’s asset pipelines (Mix/Vite). Check the package’s `composer.json` for exact version requirements, as minor updates may align with Laravel releases.
How do I handle large datasets with Choices.js in Laravel?
For large datasets, use debouncing (e.g., `->debounce(500)`) and server-side pagination. Fetch data in chunks via AJAX and update the Choices.js instance dynamically. Example: `Choices::make()->options($paginatedData)->render()`, then reload options as the user scrolls or types.
Does this package support accessibility (e.g., keyboard navigation, screen readers)?
Choices.js is built with accessibility in mind, supporting keyboard navigation and screen readers out of the box. The package inherits these features, but test your implementation thoroughly. Ensure ARIA attributes and focus states align with your design. For custom templates, validate accessibility manually.
Can I use Choices.js with Livewire or Inertia.js in Laravel?
Yes, but initialization timing is critical. For Livewire, use `@script` tags or Alpine.js to defer Choices.js setup until the component mounts. For Inertia.js, ensure the library initializes after hydration. The package itself doesn’t enforce SSR, so manual handling may be needed for seamless integration.
What are the alternatives to Choices.js in Laravel for searchable selects?
Alternatives include native HTML `<datalist>` (limited UX), Alpine.js with custom scripts (lightweight), or libraries like Select2 (feature-rich but heavier). For simple cases, Laravel’s built-in `<select>` with AJAX might suffice. Choices.js strikes a balance between performance and UX, making it ideal for complex interactions.
How do I test Choices.js integration in a Laravel application?
Test frontend behavior with JavaScript unit tests (e.g., Jest) to verify initialization, search functionality, and accessibility. For backend integration, mock API responses or database queries. Use Laravel’s testing helpers to assert DOM changes or simulate user input. Focus on edge cases like empty datasets or rapid typing.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor