Skip to main content
← Back to Table of Contents

Summary

SaaS-style boolean toggle: label and description on one side, switch on the other.
ClassBjanczak\FilamentFlexFields\Filament\Forms\Components\SwitchField
State typebool
Model cast'is_admin' => 'boolean'
FieldTypetoggle

Basic usage

use Bjanczak\FilamentFlexFields\Filament\Forms\Components\SwitchField;

SwitchField::make('notifications')
    ->label('Notifications')
    ->description('Receive email updates')
    ->badge('New')
    ->badgeColor('primary')
    ->layout('card')
    ->accepted();

Validation

MethodLaravel rule
(default)boolean
accepted()accepted — must be true
declined()declined — must be false
Parity with Filament Toggle / Checkbox validation.

Configuration API

inline(bool|Closure $condition = true)

Renders the toggle switch inline alongside other elements rather than in its own block layout.
SwitchField::make('is_active')
    ->inline(true);

inlineWithLabel(bool|Closure $condition = true)

Positions the toggle switch inline on the same row, immediately next to the label.
SwitchField::make('is_active')
    ->inlineWithLabel();

Implementation notes

  • hiddenLabel() is called in setUp() so the label renders inside the component, avoiding duplicate labels in field groups.
  • Default state: false.

FlexField schema config

Config keyMaps to
variantvariant()
layoutlayout()
sizesize()
colorcolor()
badgebadge()
badge_colorbadgeColor()
descriptiondescription()
on_coloronColor()
off_coloroffColor()
on_icononIcon()
off_iconoffIcon()
label_positionlabelPosition()
rippleripple()
compactcompact()