PHPackages                             syriable/filament-choice-fields - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. syriable/filament-choice-fields

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

syriable/filament-choice-fields
===============================

This is my package filament-choice-fields

1.0.0(today)00MITBladePHP ^8.1|^8.2|^8.3|^8.4CI passing

Since Jun 19Pushed todayCompare

[ Source](https://github.com/syriable/filament-choice-fields)[ Packagist](https://packagist.org/packages/syriable/filament-choice-fields)[ Docs](https://github.com/syriable/filament-choice-fields)[ GitHub Sponsors](https://github.com/syriable)[ RSS](/packages/syriable-filament-choice-fields/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (13)Versions (2)Used By (0)

Filament Choice Fields
======================

[](#filament-choice-fields)

[![Latest Version on Packagist](https://camo.githubusercontent.com/f3f25c139cb2c5ba7986eb1216c42f2ddf0318af829b9307089c555edda1f6bc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7379726961626c652f66696c616d656e742d63686f6963652d6669656c64732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/syriable/filament-choice-fields)[![Tests](https://camo.githubusercontent.com/89fbe71847060c6cdd065dad483736a70b774a21ade524d2a674542e0b1a402b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7379726961626c652f66696c616d656e742d63686f6963652d6669656c64732f74657374732e796d6c3f6c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/syriable/filament-choice-fields/actions/workflows/tests.yml)[![Code Style](https://camo.githubusercontent.com/df1e01da8258fe698465302b8be34bfb75ca2a3c168357eb6e612320cf98cdc6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7379726961626c652f66696c616d656e742d63686f6963652d6669656c64732f6669782d636f64652d7374796c652e796d6c3f6c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/syriable/filament-choice-fields/actions/workflows/fix-code-style.yml)[![Total Downloads](https://camo.githubusercontent.com/5cc9b691306ad9abb66025b2447d70a6192d732fd11a9b33464ac19ac7664768/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7379726961626c652f66696c616d656e742d63686f6963652d6669656c64732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/syriable/filament-choice-fields)

Filament Choice Fields adds eight rich selection fields to FilamentPHP. Four are single-choice fields based on `Radio`, and four are multiple-choice fields based on `CheckboxList`. On top of the familiar `options()` / `descriptions()` API they add card, stacked-card and table layouts, per-option icons and badges, rich HTML "extras", state-aware descriptions, and a scrollable options list.

Requirements
------------

[](#requirements)

- PHP 8.1+
- Filament 4 or 5

Installation
------------

[](#installation)

**1.** Install the package via Composer:

```
composer require syriable/filament-choice-fields
```

**2.** Make sure you have a [custom Filament theme](https://filamentphp.com/docs/4.x/styling/overview#creating-a-custom-theme). Then register the package's Blade views as a Tailwind source in your theme's CSS file so the utility classes are compiled:

```
@source '../../../../vendor/syriable/filament-choice-fields/resources/**/*.blade.php';
```

**3.** Rebuild your assets so the theme picks up the new classes:

```
npm run build
# or, while developing
npm run dev
```

Components
----------

[](#components)

All fields live in the `Syriable\Filament\Plugins\Translations\ChoiceFields\Filament\Forms\Components`namespace. Import the ones you need:

```
use Syriable\Filament\Plugins\Translations\ChoiceFields\Filament\Forms\Components\CheckboxList;
use Syriable\Filament\Plugins\Translations\ChoiceFields\Filament\Forms\Components\CheckboxCard;
use Syriable\Filament\Plugins\Translations\ChoiceFields\Filament\Forms\Components\CheckboxStackedCard;
use Syriable\Filament\Plugins\Translations\ChoiceFields\Filament\Forms\Components\CheckboxTable;
use Syriable\Filament\Plugins\Translations\ChoiceFields\Filament\Forms\Components\RadioList;
use Syriable\Filament\Plugins\Translations\ChoiceFields\Filament\Forms\Components\RadioCard;
use Syriable\Filament\Plugins\Translations\ChoiceFields\Filament\Forms\Components\RadioStackedCard;
use Syriable\Filament\Plugins\Translations\ChoiceFields\Filament\Forms\Components\RadioTable;
```

FieldSelectionLayout`CheckboxList`multipleVertical list`CheckboxCard`multipleCards`CheckboxStackedCard`multipleStacked cards`CheckboxTable`multipleResponsive table`RadioList`singleVertical list`RadioCard`singleCards`RadioStackedCard`singleStacked cards`RadioTable`singleResponsive table### CheckboxList

[](#checkboxlist)

Vertical list layout with descriptions and extras for multiple selections.

```
CheckboxList::make('delivery_type')
    ->searchable()
    ->bulkToggleable()
    ->options([
        'standard' => 'Standard Delivery',
        'express' => 'Express Delivery',
        'overnight' => 'Overnight Delivery',
        'same_day' => 'Same Day Delivery',
    ])
    ->descriptions([
        'standard' => 'Delivery within 5-7 business days',
        'express' => 'Delivery within 2-3 business days',
        'overnight' => 'Next day delivery available',
        'same_day' => 'Delivery on the same day',
    ])
    ->extras([
        'standard' => '$5.00 flat rate',
        'express' => '$10.00 flat rate',
        'overnight' => '$20.00 flat rate',
        'same_day' => '$25.00 flat rate',
    ]);
```

### CheckboxCard

[](#checkboxcard)

Card-based layout with descriptions and extras for multiple selections.

```
CheckboxCard::make('delivery_type')
    ->searchable()
    ->bulkToggleable()
    ->options([
        'standard' => 'Standard Delivery',
        'express' => 'Express Delivery',
        'overnight' => 'Overnight Delivery',
    ])
    ->descriptions([
        'standard' => 'Delivery within 5-7 business days',
        'express' => 'Delivery within 2-3 business days',
        'overnight' => 'Next day delivery available',
    ])
    ->extras([
        'standard' => '$5.00 flat rate',
        'express' => '$10.00 flat rate',
        'overnight' => '$20.00 flat rate',
    ]);
```

### CheckboxStackedCard

[](#checkboxstackedcard)

Stacked card layout with descriptions and extras for multiple selections.

```
CheckboxStackedCard::make('delivery_type')
    ->options(DeliveryTypeEnum::class)
    ->searchable()
    ->bulkToggleable();
```

### CheckboxTable

[](#checkboxtable)

Responsive table layout with descriptions for multiple selections.

```
CheckboxTable::make('delivery_type')
    ->options(DeliveryTypeEnum::class)
    ->searchable()
    ->bulkToggleable();
```

### RadioList

[](#radiolist)

Vertical list layout with descriptions.

```
RadioList::make('delivery_type')
    ->options(DeliveryTypeEnum::class);
```

### RadioCard

[](#radiocard)

Card-based layout with descriptions and extras.

```
RadioCard::make('plan')
    ->options([
        'hobby' => 'Hobby',
        'pro' => 'Pro',
    ])
    ->descriptions([
        'hobby' => 'For side projects',
        'pro' => 'For teams',
    ])
    ->extras([
        'hobby' => '$9/mo',
        'pro' => '$29/mo',
    ]);
```

### RadioStackedCard

[](#radiostackedcard)

Stacked card layout with descriptions and extras.

```
RadioStackedCard::make('delivery_type')
    ->options(DeliveryTypeEnum::class);
```

### RadioTable

[](#radiotable)

Responsive table layout with descriptions.

```
RadioTable::make('delivery_type')
    ->options(DeliveryTypeEnum::class);
```

Search, bulk actions, and disabling options
-------------------------------------------

[](#search-bulk-actions-and-disabling-options)

These behaviours are inherited unchanged from FilamentPHP's `Radio` and `CheckboxList` APIs.

Search:

```
CheckboxList::make('delivery_type')
    ->options(DeliveryTypeEnum::class)
    ->searchable()
    ->searchPrompt('Search delivery types...')
    ->noSearchResultsMessage('No delivery types found.');
```

Bulk select (checkbox-style fields only):

```
CheckboxList::make('delivery_type')
    ->options(DeliveryTypeEnum::class)
    ->bulkToggleable();
```

Disable a single option:

```
CheckboxList::make('delivery_type')
    ->options(DeliveryTypeEnum::class)
    ->disableOptionWhen(fn (string $value): bool => $value === 'premium');
```

Enum support
------------

[](#enum-support)

Pass a backed enum class name to `options()` instead of an array. The enum can implement Filament's contracts to provide its label and description:

- `Filament\Support\Contracts\HasLabel` — the main label
- `Filament\Support\Contracts\HasDescription` — the subtitle

```
