Weave 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

Bootstrap Switch Laravel Package

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.

Deep Wiki
Context7

Technical Evaluation

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

  • Good fit only where the presentation layer is Blade + jQuery + Bootstrap 3.x. This profile matches Laravel 5.x–8.x applications that were built before the Vite/Livewire/Tailwind transition, which is the primary surviving adoption pool.
  • Poor fit for Laravel 9+ greenfield work: Bootstrap 4/5 (Bootstrap 5 ships a native .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.
  • The plugin is not a "component library" in the modern sense — it mutates an existing input into a sibling wrapper element. That mutation model is the core architectural liability in any reactive front end.

Integration feasibility

  • Mechanically trivial: drop the two dist files into 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.
  • Bundling works with both Laravel Mix and Vite; the only Vite-specific friction is ensuring jQuery is exposed globally before the plugin module evaluates.
  • Low integration effort, but the effort is not the risk — maintenance is.

Technical risk

  • Unmaintained since 2017-02-25. The 5,025 stars are accumulated 2013–2017 mindshare and are a lagging indicator, not evidence of current viability. The opportunity score of 26.25 is consistent with a saturated, EOL component.
  • Version lock: tied to Bootstrap 3 markup conventions; forks and community patches exist but are unaudited supply-chain additions. Pinning 3.3.4 and vendoring the dist files is the only defensible consumption model.
  • jQuery coupling forces a global that modern Laravel front ends deliberately avoid; it will be a permanent exception in any migration plan.
  • Accessibility debt: generated markup, focus handling, and label association pass casual review but are not audited against current WCAG expectations; keyboard and screen-reader behavior should be validated rather than assumed.
  • XSS surface (low but real): 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.
  • CSP surface: the plugin applies inline styles/widths; a strict style-src policy needs 'unsafe-inline' or a nonce strategy, or the control renders broken.

Key questions for the requestor

  1. Which Bootstrap major version does the target app use? (If 4/5, stop here and use native switches.)
  2. Is jQuery already a first-class dependency in the bundle, or would this introduce it?
  3. Is this a legacy screen being maintained, or a greenfield feature? (Determines whether this is acceptable technical debt or an avoidable one.)
  4. Does the surface render dynamically (Livewire, Turbo, HTMX, DataTables, infinite scroll)? If so, who owns re-initialization?
  5. Is there an accessibility conformance requirement (WCAG 2.1 AA) that mandates audited form controls?
  6. What is the Content-Security-Policy, and can it tolerate inline styles?
  7. Is a vendored, frozen, internally-owned asset acceptable to the team that will carry it?

Integration Approach

Stack fit

  • Proceed for Laravel apps on Bootstrap 3 + jQuery + server-rendered Blade, especially admin/back-office panels where consistent form ergonomics matter more than modern tooling.
  • Do not proceed for Bootstrap 4/5, Tailwind, Alpine, Livewire-owned DOM, or SPA front ends. In those stacks the replacement cost is lower than the integration-plus-ownership cost.
  • Where the app is mid-migration (e.g., Bootstrap 3 today, 5 next year), treat this as a transitional adoption only if the toggle count is small and the migration date is known.

Migration/installation path (Laravel-specific)

  1. Pin and vendor: 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).
  2. Attach jQuery globally before the plugin: window.$ = window.jQuery = $ in resources/js/bootstrap.js.
  3. Import the plugin in the same entry point, after jQuery, and the CSS in resources/css/app.css (or a dedicated forms.css).
  4. Create one Blade component (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>.
  5. Centralize initialization in one idempotent module: initSwitches(root = document) that skips already-initialized nodes (if ($el.data('bootstrapSwitch')) return;). This is the single most important design decision.

Compatibility notes

  • Bootstrap 3.x CSS only. Verify against the exact patch level in use; Bootstrap 4+ breaks sizing and color classes.
  • jQuery 1.9+ through 3.x is broadly reported working but should be spiked against the app's exact jQuery version.
  • Server-side validation: Laravel's 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

  1. Inventory current toggle usage and confirm Bootstrap/jQuery versions (1 hour).
  2. Spike one real form in a branch; validate submit, validation-error re-render, and mobile touch (half day).
  3. Build the <x-toggle> component and the idempotent initializer; document options in the repo README (1 day).
  4. Handle dynamic surfaces: hook Livewire's morph/navigation events or add wire:ignore; for Turbo/HTMX, re-init on the relevant lifecycle event (half day, only if applicable).
  5. Accessibility pass on the wrapped control; record findings.
  6. Freeze the version, add an ADR noting the package is EOL and naming an owner and an exit path.

Operational Impact

Maintenance

  • Effective upstream maintenance is zero. Treat the vendored copy as first-party code: it appears in your repo, your review process, and your dependency-audit exception list. Nominate an owner.
  • No security patching path exists. The mitigation is a small, static, client-side surface with no network or server-side behavior — the blast radius of a future CVE is limited, but you cannot rely on upstream to tell you.
  • Dependency-audit tooling will either flag it as unmaintained or silently pass it; either outcome means the risk is invisible unless documented.

Support

  • Community answers exist in volume but are frozen in the 2014–2017 era; expect StackOverflow solutions that reference Bootstrap 2/3 idioms and older jQuery.
  • Internal support cost is low per incident but concentrated in whoever wrote the initializer. Document the component and the init contract.

Scaling

  • Runtime cost is negligible per control (a wrapper element plus a hidden input). The only scaling concern is page density: instantiating hundreds of switches in a large data table or settings matrix produces measurable DOM and layout cost. Mitigate by initializing visible rows only or lazily on scroll. No server-side, queue, or database implications whatsoever.

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.
  • Duplicate wrappers after Livewire/Turbo/HTMX navigation or partial re-render — the signature failure of this package in modern Laravel. Idempotent init or wire:ignore is mandatory.
  • State desync: input changed programmatically (e.g., "select all") without firing the plugin's refresh, so the visual lags the value. Use the plugin's state method or trigger the input's change.
  • Form submission regressions on array names, required, and disabled inputs.
  • CSP blocking inline styles → collapsed or mis-sized control.
  • Localization gaps: on/off text is per-instance 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

  • A mid-level Laravel developer can integrate and ship a single form in under a day; a robust, reusable, dynamically-safe implementation is 1.5–2 days.
  • The real ramp-up cost is knowledge decay: developers joining after 2020 may have no jQuery plugin experience, and the plugin's option/event API (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.

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.
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource