PHPackages                             wamesk/laravel-nova-inline-toggle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. wamesk/laravel-nova-inline-toggle

ActiveLibrary

wamesk/laravel-nova-inline-toggle
=================================

A Laravel Nova inline toggle/switch field with index page inline editing.

1.1.0(1mo ago)06MITVuePHP ^8.2

Since Mar 12Pushed 1mo agoCompare

[ Source](https://github.com/wamesk/laravel-nova-inline-toggle)[ Packagist](https://packagist.org/packages/wamesk/laravel-nova-inline-toggle)[ RSS](/packages/wamesk-laravel-nova-inline-toggle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

Laravel Nova Inline Toggle
==========================

[](#laravel-nova-inline-toggle)

A Laravel Nova field that renders a toggle/switch with **inline editing** on the index page. Click the toggle directly in the resource table to update the value — no need to open the edit form.

Features
--------

[](#features)

- Toggle switch on **index** page with inline update (no page reload)
- Configurable **on/off colors**
- Read-only badge or inline toggle on **detail** page
- Standard checkbox on **form** page
- Customizable **success/error messages** (per state or general)
- **`dependsOn`** support — reactively show/hide or modify the field based on other field values
- **Readonly** support on index and detail toggle buttons
- Works with any boolean/tinyint column
- Compatible with `->sortable()` and `->filterable()`

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel Nova 4.x
- Laravel 11.x

Installation
------------

[](#installation)

```
composer require wamesk/laravel-nova-inline-toggle
```

The service provider is auto-discovered — no manual registration needed. Pre-built assets are included in the package.

Usage
-----

[](#usage)

### Basic

[](#basic)

```
use Wame\InlineToggle\InlineToggle;

public function fields(NovaRequest $request): array
{
    return [
        // ...

        InlineToggle::make(__('Active'), 'is_active'),
    ];
}
```

This renders a green/gray toggle switch on the index page and a read-only badge on the detail page.

### Colors

[](#colors)

Customize the toggle colors using hex values:

```
InlineToggle::make(__('Reminders Paused'), 'reminders_paused')
    ->onColor('#FDE047')   // yellow when ON
    ->offColor('#9ca3af')  // gray when OFF (default)
```

**Defaults:**

- `onColor`: `#22c55e` (green)
- `offColor`: `#9ca3af` (gray)

The detail page badge automatically uses the configured color as its background and calculates a contrasting text color (dark or white).

### Inline Toggle on Detail Page

[](#inline-toggle-on-detail-page)

By default, the detail page shows a read-only ON/OFF badge. To enable the inline toggle on detail as well:

```
InlineToggle::make(__('Active'), 'is_active')
    ->inlineOnDetail()
```

### Custom Messages

[](#custom-messages)

#### General message (shown for both ON and OFF)

[](#general-message-shown-for-both-on-and-off)

```
InlineToggle::make(__('Active'), 'is_active')
    ->successMessage(__('Status updated.'))
    ->errorMessage(__('Failed to update status.'))
```

#### Per-state messages

[](#per-state-messages)

```
InlineToggle::make(__('Reminders Paused'), 'reminders_paused')
    ->onMessage(__('Reminders have been paused.'))
    ->offMessage(__('Reminders have been resumed.'))
    ->errorMessage(__('Failed to update reminder status.'))
```

**Message priority:** `onMessage`/`offMessage` &gt; `successMessage` &gt; default English fallback.

### DependsOn

[](#dependson)

Use Nova's `dependsOn()` to reactively control the field based on other field values:

```
use Laravel\Nova\Http\Requests\NovaRequest;
use Laravel\Nova\Fields\FormData;

InlineToggle::make(__('Active'), 'is_active')
    ->dependsOn('status', function (InlineToggle $field, NovaRequest $request, FormData $formData) {
        if ($formData->status === 'archived') {
            $field->hide();
        }
    });
```

You can also use it to dynamically change field properties:

```
InlineToggle::make(__('Featured'), 'is_featured')
    ->dependsOn('type', function (InlineToggle $field, NovaRequest $request, FormData $formData) {
        if ($formData->type === 'premium') {
            $field->onColor('#F59E0B');
        }
    });
```

The field also emits change events, so other fields can depend on it:

```
Text::make('Label')
    ->dependsOn('is_active', function (Text $field, NovaRequest $request, FormData $formData) {
        $field->value = $formData->boolean('is_active') ? 'Enabled' : 'Disabled';
    });
```

### Readonly

[](#readonly)

The toggle respects Nova's `readonly()` method on all views (index, detail, and form):

```
InlineToggle::make(__('Active'), 'is_active')
    ->readonly()
```

### Sorting &amp; Filtering

[](#sorting--filtering)

The field supports Nova's built-in sorting and filtering:

```
InlineToggle::make(__('Active'), 'is_active')
    ->sortable()
    ->filterable()
```

### Full Example

[](#full-example)

```
use Wame\InlineToggle\InlineToggle;

InlineToggle::make(__('invoice::invoice.field.reminders_paused'), 'reminders_paused')
    ->onColor('#FDE047')
    ->offColor('#9ca3af')
    ->inlineOnDetail()
    ->onMessage(__('invoice::invoice.toggle.reminders_paused_on'))
    ->offMessage(__('invoice::invoice.toggle.reminders_paused_off'))
    ->errorMessage(__('invoice::invoice.toggle.error'))
    ->dependsOn('status', function (InlineToggle $field, NovaRequest $request, FormData $formData) {
        if ($formData->status === 'paid') {
            $field->readonly();
        }
    })
    ->sortable()
    ->filterable(),
```

API Reference
-------------

[](#api-reference)

MethodDescriptionDefault`onColor(string $color)`Hex color when toggle is ON`#22c55e``offColor(string $color)`Hex color when toggle is OFF`#9ca3af``inlineOnDetail(bool $value = true)`Enable inline toggle on detail page`false` (read-only badge)`successMessage(string $message)`General success toast message`"The field was updated successfully."``onMessage(string $message)`Success toast when toggled ONFalls back to `successMessage``offMessage(string $message)`Success toast when toggled OFFFalls back to `successMessage``errorMessage(string $message)`Error toast message`"There was a problem updating the field."``dependsOn($attributes, $callback)`Register dependent field callback—`readonly($value = true)`Disable toggle interaction`false`How It Works
------------

[](#how-it-works)

- **Index page:** Renders a CSS toggle switch. On click, sends a POST request to `/nova-vendor/inline-toggle/update/{resource}` which updates the model attribute directly.
- **Detail page:** Shows a colored ON/OFF badge by default. With `->inlineOnDetail()`, renders the same interactive toggle as on the index.
- **Form page:** Renders a standard checkbox.

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance89

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

58d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2bf6ece61ae07942df38ce88eb4053d4176c6ab0bf803191953961023f25fc70?d=identicon)[WAME](/maintainers/WAME)

---

Top Contributors

[![adrianzofcin](https://avatars.githubusercontent.com/u/75702986?v=4)](https://github.com/adrianzofcin "adrianzofcin (4 commits)")

---

Tags

laraveltoggleinlinenova

### Embed Badge

![Health badge](/badges/wamesk-laravel-nova-inline-toggle/health.svg)

```
[![Health](https://phpackages.com/badges/wamesk-laravel-nova-inline-toggle/health.svg)](https://phpackages.com/packages/wamesk-laravel-nova-inline-toggle)
```

###  Alternatives

[dillingham/nova-attach-many

Attach Many Nova field

2712.0M2](/packages/dillingham-nova-attach-many)[sbine/route-viewer

A Laravel Nova tool to view your registered routes.

57215.9k](/packages/sbine-route-viewer)[markwalet/nova-modal-response

A Laravel Nova asset for Modal responses on an action.

14720.0k](/packages/markwalet-nova-modal-response)[outl1ne/nova-inline-text-field

A Laravel Nova inline text field.

23252.9k2](/packages/outl1ne-nova-inline-text-field)[stepanenko3/nova-cards

A Laravel Nova info cards.

33143.0k](/packages/stepanenko3-nova-cards)[optimistdigital/nova-inline-text-field

A Laravel Nova inline text field.

2321.3k](/packages/optimistdigital-nova-inline-text-field)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
