okipa/laravel-toggle-switch-button

This package is abandoned and no longer maintained. The author suggests using the https://github.com/Okipa/laravel-bootstrap-components package instead.

A customizable toggle switch button generator for Laravel.

2.0.5 2018-06-11 14:52 UTC

This package is not auto-updated.

Last update: 2022-02-01 13:07:49 UTC


README

Package abandonned in profit of https://github.com/Okipa/laravel-bootstrap-components package.

Source Code Latest Version Total Downloads License: MIT Code Coverage Scrutinizer Code Quality

A customizable and configurable toggle switch button generator for Laravel that enables you to simply display it on your projects pages.

Laravel Toggle Switch Button

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 or CSS 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.

Contributors