Download the PHP package almirhodzic/nova-toggle-5 without Composer
On this page you can find all versions of the php package almirhodzic/nova-toggle-5. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download almirhodzic/nova-toggle-5
More information about almirhodzic/nova-toggle-5
Files in almirhodzic/nova-toggle-5
Package nova-toggle-5
Short Description A Laravel Nova 5 toggle field that allows quick boolean updates directly from the index view.
License MIT
Homepage https://novafront.dev
Informations about the package nova-toggle-5
Laravel Nova 5 Toggle Field
This Laravel Nova 5 Toggle Field removes the detour into the edit page and lets you flip booleans directly in the index. Fewer clicks, less context switching, smoother workflow.

Features
- Quick toggle directly from index view
- Customizable colors for light and dark mode
- Built-in readonly and visibility controls
- Optional help text for different views
- Custom ON/OFF labels with color customization
- Optional toast notification control
- Customizable toast message labels
- Filter support for index views
- Logs the update action in Nova's action events
- Vue 3 Composition API
- Full dark mode support
Requirements
- PHP 8.2+
- Laravel Nova 5.x
Installation
The service provider will be automatically registered.
Upgrading from 1.2 to 1.3
Version 1.3.0 contains a security fix that changes how the toggle endpoint is
authorized. For most installations the upgrade is a drop-in: just run
composer update almirhodzic/nova-toggle-5.
What changed:
- The toggle endpoint is now protected by Nova's own
nova:apimiddleware. Only users who pass theviewNovagate can reach it. - The controller additionally checks the resource's
authorizedToUpdatepolicy and only allows writes to attributes that are actually exposed as aTogglefield on the resource. - The
config/nova-toggle-5.phpfile (with itsguardsoption) has been removed. If you previously published it, you can delete it — it is no longer read.
If you were relying on the old guards config to grant toggle access to users
that do not pass the viewNova gate, make sure those users are now either
allowed by the gate or no longer need toggle access.
Basic Usage
Configuration
Colors
Toggle Background Colors
Bullet Colors
Labels
Custom ON/OFF Text
Label Colors
Toast Notifications
Custom Toast Label
By default, the toast message uses the resource's name, label, title, or the resource's singular label. You can customize which model attribute to use:
Default fallback order: name → label → title → resource singular label
Disable Toast Notifications
Filtering
To make your toggle field filterable in the index view, you need to create a custom filter.
Step 1: Create a Filter
Step 2: Implement the Filter
Step 3: Register the Filter in Your Resource
Alternative: Boolean Filter (Checkboxes)
If you prefer checkboxes instead of a dropdown:
Now use
Help Text
Add contextual help text for different views:
Visibility & Access Control
Hide Based on Condition
Readonly Based on Condition
Authorization
Toggle requests are protected by Nova's own API middleware, so only users who pass Nova's
viewNova gate can reach the endpoint. On top of that, the controller enforces the
resource's authorizedToUpdate policy and only allows writes to attributes that are actually
exposed as a Toggle field on the resource (and are not readonly in the current context).
No additional configuration is required — the toggle follows the same access rules as Nova itself.
Complete Example
API Reference
Methods
| Method | Parameters | Description |
|---|---|---|
onColor() |
string $light, ?string $dark = null |
Background color when ON |
offColor() |
string $light, ?string $dark = null |
Background color when OFF |
onBullet() |
string $light, ?string $dark = null |
Bullet color when ON |
offBullet() |
string $light, ?string $dark = null |
Bullet color when OFF |
valueLabelText() |
?string $onLabel = 'ON', ?string $offLabel = 'OFF' |
Custom label text |
valueLabelOnColors() |
string $light, ?string $dark = null |
ON label color |
valueLabelOffColors() |
string $light, ?string $dark = null |
OFF label color |
toastShow() |
bool $show = true |
Show/hide toast notification on toggle |
toastLabelKey() |
string $key |
Model attribute to use for toast label |
hideWhen() |
callable $callback |
Hide field based on condition |
readonlyWhen() |
callable $callback |
Make readonly based on condition |
helpOnIndex() |
string $text |
Help text on index view |
helpOnForm() |
string $text |
Help text on form view |
helpOnDetail() |
string $text |
Help text on detail view |
Default Colors
| State | Light Mode | Dark Mode |
|---|---|---|
| ON Background | #00d5be |
#009689 |
| OFF Background | #e5e5e5 |
#323f57 |
| ON Bullet | #ffffff |
#ffffff |
| OFF Bullet | #ffffff |
#ffffff |
| ON Label | #ffffff |
#ffffff |
| OFF Label | #a1a1a1 |
#737373 |
Default Behavior
| Option | Default Value |
|---|---|
toastShow |
true |
toastLabelKey |
null (uses fallback: name → label → title → resource singular label) |
Bug or Issues
Found a Bug or Issue? Please report here: GitHub Issues
We appreciate your feedback to help improve this package.
Support
License
The MIT License (MIT). Please see License File for more information.
Credits
- Almir Hodzic
- All Contributors
By Frontbyte