naif/toggle-switch-field

A Toggle Switch Field for Nova 4.

1.1.4 2024-03-19 13:50 UTC

This package is not auto-updated.

Last update: 2024-05-15 17:16:43 UTC


README

Toggle Switch Field for Nova 4

For Toggle Switch Field for Nova 3 go to https://github.com/naifalshaye/toggle-switch

Features:

  • Set custom color using hex color code
  • Toggle or Icon align. Default (left)
  • Toggle Switch in Index to update value instead of icons. Default (true)
  • Toggle Switch in Detail to update value instead of icons. Default (true)

Requirements

  • PHP 8.0 or higher
  • Nova 4

Installation

You can install the package into a Laravel app that uses Nova via composer:

composer require naif/toggle-switch-field

Usage

Table column migration

$table->boolean('toggle')->nullable()->default(true);

Add the field to Nova Resource

  public function fields(NovaRequest $request)
    {
        return [
           ToggleSwitchField::make('Toggle','toggle')
                ->color('#3AB95A')
                ->toggleAlign('center')
                ->indexToggle(false)
                ->detailToggle(false),
        ];
    }

Screenshots

Custom hex color code

img.png

Detail Page Toggle Switch On

detail-toggle-on.png
dark-detail-toggle-on.png

Detail Page Toggle Switch Off

detail-toggle-off.png
dark-detail-toggle-off.png

Detail Page Icons On

detail-on.png
dark-detail-on.jpg

Detail Page Icons Off

detail-off.png
dark-detail-off.png

Edit Page Toggle Switch On

img_1.png
on.png
dark-on.png

Edit Page Toggle Switch Off

img_2.png
off.png
dark-off.png

Index Page Toggle Switch

index-toggle.png
dark-index-toggle.png

Index Page icons

index.png
dark-index.png

Support:

naif@naif.io

https://naif.io

Bug Tracker:

https://github.com/naifalshaye/toggle-switch-field/issues

License

The MIT License (MIT). Please see License File for more information.