nostalgiaz/bootstrap-switch
Bootstrap Switch turns checkboxes and radio buttons into attractive, customizable toggle switches for Bootstrap. This Composer package bundles the plugin assets for easy integration into Laravel and PHP projects, with support for sizes, colors, labels, and events.
Framing correction (important): despite the ticket describing this as a "Laravel/PHP package," nostalgiaz/bootstrap-switch is not a Composer package and contains no PHP. It is a client-side jQuery plugin (plus CSS) that decorates <input type="checkbox"> / <input type="radio"> elements into toggle switches, targeting Bootstrap 3.x. There is no service provider, no facade, no Blade directive, no config publish tag, and no composer require path. The relevant evaluation is therefore frontend-fit within a Laravel-rendered Blade surface, not PHP-package fit.
Architecture fit
.form-switch), Tailwind, Alpine.js, Livewire-first, or Inertia/Vue/React front ends. The plugin assumes a mutable DOM and a global jQuery, which conflicts with component-owned rendering and DOM diffing.Integration feasibility
resources/js/resources/css (or npm i [email protected]), import after jQuery is attached to window, and call $('[data-toggle="switch"]').bootstrapSwitch() once on page load. A reusable <x-toggle> Blade component is roughly a half-day of work.Technical risk
3.3.4 and vendoring the dist files is the only defensible consumption model.data-label-text, data-on-text, and similar attributes are interpolated into rendered markup. Any Blade usage that pipes user- or tenant-controlled strings into these attributes without escaping is an injection vector. Enforce {{ }} and forbid {!! !!} in these attributes via code review.style-src policy needs 'unsafe-inline' or a nonce strategy, or the control renders broken.Key questions for the requestor
Stack fit
Migration/installation path (Laravel-specific)
npm i [email protected] --save-exact, then either import from node_modules or copy dist/css/bootstrap3/bootstrap-switch.css and dist/js/bootstrap-switch.js into resources/ to remove npm supply-chain dependence. Preserve the MIT license header (attribution obligation).window.$ = window.jQuery = $ in resources/js/bootstrap.js.resources/css/app.css (or a dedicated forms.css).resources/views/components/toggle.blade.php) that emits the raw checkbox with its name/value/checked/validation state, plus data-* options, and a single @once script block or a global initializer — not per-instance inline <script>.initSwitches(root = document) that skips already-initialized nodes (if ($el.data('bootstrapSwitch')) return;). This is the single most important design decision.Compatibility notes
old() and @error state must be reflected on the underlying input before initialization, since the plugin renders from the input's checked property, not from markup it generates.disabled, readonly, required, and name[] array inputs need explicit test coverage — these are the classic regression points.Sequencing
<x-toggle> component and the idempotent initializer; document options in the repo README (1 day).wire:ignore; for Turbo/HTMX, re-init on the relevant lifecycle event (half day, only if applicable).Maintenance
Support
Scaling
Failure modes to watch
$.fn.bootstrapSwitch is not a function — jQuery loaded after the plugin, or the plugin tree-shaken out of the Vite build.wire:ignore is mandatory.state method or trigger the input's change.required, and disabled inputs.data-on-text/data-off-text; there is no i18n layer, so translation strings must be supplied from Laravel's __() at render time.Ramp-up
switchChange.bootstrapSwitch, size, animate, onColor) is undocumented in-repo unless you write it down. Budget the README.Recommendation
Conditionally adopt as a frozen, vendored, internally-owned UI asset for legacy Bootstrap 3 Blade surfaces with a small toggle footprint, wrapped behind a single Blade component so the eventual replacement with Bootstrap 5's native .form-switch (or a Tailwind/Alpine equivalent) is a one-file change. Decline for greenfield or modern-stack Laravel work — the 2017 EOL date, jQuery coupling, and Bootstrap 3 lock make the total cost of ownership exceed the ~half-day of styling the control natively.
How can I help you explore Laravel packages today?