A small package featuring two simple components that serve as excellent alternatives to toggles, radio buttons, and other selectors. These components not only offer seamless user interactions but also maintain UI consistency by effortlessly aligning with neighboring fields and components.
You can install the package via composer:
composer require andrewdwallo/filament-selectify
Optionally, you can publish the views using
php artisan vendor:publish --tag="filament-selectify-views"
In order for component styles to be processed, you must add this package's vendor directory into the content array of your tailwind.config.js
file:
export default { content: [ './resources/**/*.blade.php', './vendor/filament/**/*.blade.php', './vendor/andrewdwallo/filament-selectify/resources/views/**/*.blade.php', // The package's vendor directory ], // ...}
The ToggleButton has the following options. The onLabel()
and offLabel()
represent the true and false states. You may also customize the color representing each state using onColor()
and offColor()
.
ToggleButton::make('enabled') ->offColor('danger') ->onColor('primary') ->offLabel('No') ->onLabel('Yes') ->default(true),
The ButtonGroup has the following options. You may customize the color representing each state. The onColor()
represents the button or value that is selected and the offColor()
represents the button or value that is not selected. You may use gridDirection()
to change the layout of the buttons. The options are column
and row
. The default is column
.
You may optionally add icons for the buttons using icons()
and supplying an array that contains the option values as keys and icon names as values. Icon position and size can be changed using iconPosition()
(default: before) and iconSize()
(default: Small).
ButtonGroup::make('entity') ->options([ 'individual' => 'Individual', 'company' => 'Company', ]) ->onColor('primary') ->offColor('gray') ->gridDirection('row') ->default('individual') ->icons([ 'individual' => 'heroicon-m-user', 'company' => 'heroicon-m-building-office', ]) ->iconPosition(\Filament\Support\Enums\IconPosition::After) ->iconSize(Filament\Support\Enums\IconSize::Medium),
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.