okipa / laravel-toggle-switch-button
A customizable toggle switch button generator for Laravel.
Installs: 1 332
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 2
Open Issues: 0
Requires
- php: >=7.0
- illuminate/support: ~5.0
- okipa/laravel-html-helper: ^1.0
Requires (Dev)
- orchestra/testbench: ^3.6
README
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.
Installation
Versions
- V1 :
composer require okipa/laravel-toggle-switch-button:^1.0.0
- V2 :
composer require okipa/laravel-toggle-switch-button:^2.0.0
For Laravel >=5.4 only
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);
Styles import
- Load the package
SASS
orCSS
file from the[path/to/composer/vendor]/okipa/laravel-toggle-switch-button/styles
directory to your project.
Usage
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') }}
API
Public methods See the available public methods in the ToggleSwitchButton class
Customize styles
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';
Customize templates
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.