Package abandonned in profit of https://github.com/Okipa/laravel-bootstrap-components package.
A customizable and configurable toggle switch button generator for Laravel that enables you to simply display it on your projects pages.
- V1 :
composer require okipa/laravel-toggle-switch-button:^1.0.0
- V2 :
composer require okipa/laravel-toggle-switch-button:^2.0.0
Add the package service provider in the register()
method from your app/Providers/AppServiceProvider.php
:
// laravel toggle switch button
// https://github.com/Okipa/laravel-toggle-switch-button
$this->app->register(Okipa\LaravelToggleSwitchButton\ToggleSwitchButtonServiceProvider::class);
- Load the package
SASS
orCSS
file from the[path/to/composer/vendor]/okipa/laravel-toggle-switch-button/styles
directory to your project.
Since the toggle switch button implements the Htmlable
interface, just call it this way in your blade file :
{{ toggleSwitchButton()
->name('active')
->checked(old('active') or $model->active)
->icon('<i class="fas fa-power-off"></i>')
->label('Activation') }}
Public methods See the available public methods in the ToggleSwitchButton class
If you use CSS
, just override the package styles.
If you use SASS
, you can override the following variables before the package SASS file import. Check the following example for a bootstrap use :
// bootstrap 4 example
$toggle-switch-button-label-background-color: $input-group-addon-bg;
$toggle-switch-button-label-border-color: $input-group-addon-border-color;
$toggle-switch-button-label-font-size: $font-size-base;
$toggle-switch-button-unchecked-background-color: $input-group-addon-border-color;
$toggle-switch-button-checked-background-color: $primary;
$toggle-switch-button-label-border-radius: $btn-border-radius;
@import '[path/to/composer/vendor]/okipa/laravel-toggle-switch-button/styles/styles';
Publish the package blade templates file in your project :
php artisan vendor:publish --tag=toggle-switch-button::views
Then, change the content from your resources/views/vendor/components/switch-button.blade.php
file.