codewithdennis/filament-advanced-choice
Adds 8 advanced Filament form fields: radio- and checkbox-based card/stacked card variants plus enhanced CheckboxList with descriptions and extras. Supports Filament v4/v5 and integrates into custom themes via @source for proper styling.
composer require codewithdennis/filament-advanced-choice
resources/css/filament/filament.css), include:
@source '../../../../vendor/codewithdennis/filament-advanced-choice/resources/**/*.blade.php';
npm run build
or
npm run dev
Replace a basic Radio or CheckboxList field in a Filament form with a visually enhanced alternative. For example, replace:
Radio::make('status')->options([
'active' => 'Active',
'inactive' => 'Inactive',
]),
with:
RadioCard::make('status')
->options([
'active' => 'Active',
'inactive' => 'Inactive',
])
->descriptions([
'active' => 'User is active and can access all features',
'inactive' => 'User account is suspended',
]);
Radio or CheckboxList for simple selections.RadioCard, CheckboxCard, etc., for richer UX with descriptions and extras.
// Basic
Radio::make('priority')->options([
'low' => 'Low',
'medium' => 'Medium',
'high' => 'High',
]);
// Enhanced
RadioStackedCard::make('priority')
->options([
'low' => 'Low',
'medium' => 'Medium',
'high' => 'High',
])
->descriptions([
'low' => 'Non-urgent tasks',
'medium' => 'Moderate urgency',
'high' => 'Critical tasks',
])
->extras([
'low' => 'Due in 7+ days',
'medium' => 'Due in 3-7 days',
'high' => 'Due in <3 days',
]);
HasLabel, HasDescription, and HasExtra interfaces:
enum TaskPriorityEnum: string implements HasLabel, HasDescription, HasExtra
{
case Low;
case Medium;
case High;
public function getLabel(): string
{
return match ($this) {
self::Low => 'Low Priority',
self::Medium => 'Medium Priority',
self::High => 'High Priority',
};
}
public function getDescription(): string
{
return match ($this) {
self::Low => 'Non-urgent tasks',
self::Medium => 'Moderate urgency',
self::High => 'Critical tasks',
};
}
public function getExtra(): ?string
{
return match ($this) {
self::Low => 'Due in 7+ days',
self::Medium => 'Due in 3-7 days',
self::High => 'Due in <3 days',
};
}
}
RadioCard::make('priority')->options(TaskPriorityEnum::class);
CheckboxCard::make('tags')
->options([
'bug' => 'Bug',
'feature' => 'Feature',
'documentation' => 'Documentation',
'enhancement' => 'Enhancement',
])
->searchable()
->bulkToggleable()
->searchPrompt('Search tags...')
->noSearchResultsMessage('No tags found.');
CheckboxList::make('features')
->options([
'notifications' => 'Email Notifications',
'analytics' => 'Analytics Dashboard',
'api_access' => 'API Access',
])
->disableOptionWhen(fn (string $value): bool => $value === 'api_access' && auth()->user()->cannot('access-api'));
RadioCard::make('plan')
->options(PlanEnum::class)
->color(Color::Emerald)
->hiddenInputs();
required, min_items, max_items):
CheckboxList::make('permissions')
->options(PermissionEnum::class)
->required()
->minItems(1)
->maxItems(5);
Tables\Columns\CheckboxColumn::make('is_active')
->label('Status')
->trueValue('active')
->falseValue('inactive')
->options([
'active' => 'Active',
'inactive' => 'Inactive',
])
->color(fn (string $state): string => match ($state) {
'active' => 'success',
default => 'danger',
});
trait UsesAdvancedChoiceFields
{
protected function configureDeliveryTypeField(): RadioStackedCard
{
return RadioStackedCard::make('delivery_type')
->options(DeliveryTypeEnum::class)
->searchable()
->bulkToggleable();
}
}
RadioCard::make('language')
->options([
'en' => __('English'),
'es' => __('Spanish'),
'fr' => __('French'),
])
->descriptions([
'en' => __('English (US)'),
'es' => __('Español (Latinoamérica)'),
'fr' => __('Français'),
]);
$this->get('/admin/resources/tasks/create')
->assertSee('RadioCard')
->assertSee('High Priority');
@source directive is correctly added to your Filament theme CSS file and rebuild assets.
npm run build
HasLabel, HasDescription, HasExtra for extras).
enum MyEnum: string implements HasLabel, HasDescription, HasExtra
{
// ...
}
hiddenInputs() and ensure the field is properly bound in your model/form.
RadioCard::make('status')
->options(StatusEnum::class)
->hiddenInputs();
searchable() is called and the field is properly configured in a form or table.
CheckboxList::make('tags')->options(TagEnum::class)->searchable();
CheckboxList, CheckboxCard, etc.). Ensure the field is configured correctly.
CheckboxCard::make('permissions')->options(PermissionEnum::class)->bulkToggleable();
!important sparingly or inspect which CSS rule is taking precedence.APP_DEBUG=true in your .env to see any underlying errors or warnings.Color class:
RadioCard::make('priority')
How can I help you explore Laravel packages today?