Skip to main content
The toggle component allows you to interact with a boolean value using a switch UI.

Basic Usage

use Filament\Forms\Components\Toggle;

Toggle::make('is_admin')

Available Methods

inline
method
Controls the label position (inline or stacked).
// Inline (default) - label adjacent to toggle
Toggle::make('is_admin')
    ->inline()

// Stacked - label above toggle
Toggle::make('is_admin')
    ->inline(false)
onIcon
method
Sets the icon displayed when toggled on.
use Filament\Support\Icons\Heroicon;

Toggle::make('is_admin')
    ->onIcon(Heroicon::Bolt)
offIcon
method
Sets the icon displayed when toggled off.
use Filament\Support\Icons\Heroicon;

Toggle::make('is_admin')
    ->offIcon(Heroicon::User)
onColor
method
Sets the color when toggled on.
Toggle::make('is_admin')
    ->onColor('success')
offColor
method
Sets the color when toggled off.
Toggle::make('is_admin')
    ->offColor('danger')
accepted
method
Requires the toggle to be on.
Toggle::make('terms_of_service')
    ->accepted()
declined
method
Requires the toggle to be off.
Toggle::make('is_under_18')
    ->declined()

Common Patterns

Feature Flag

Toggle::make('is_active')
    ->label('Active')
    ->onColor('success')
    ->offColor('gray')
    ->default(true)

With Icons

use Filament\Support\Icons\Heroicon;

Toggle::make('notifications_enabled')
    ->label('Enable Notifications')
    ->onIcon(Heroicon::Bell)
    ->offIcon(Heroicon::BellSlash)
    ->onColor('success')

Status Toggle

Toggle::make('published')
    ->label('Published')
    ->onColor('success')
    ->offColor('danger')
    ->inline()

Database Casting

When saving boolean values with Eloquent, add a boolean cast:
use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
    protected function casts(): array
    {
        return [
            'is_admin' => 'boolean',
        ];
    }
}

Build docs developers (and LLMs) love