Skip to main content
ChoiceCards ← Back to Table of Contents

Summary

SaaS-style single-select card group (radio behaviour).
ClassBjanczak\FilamentFlexFields\Filament\Forms\Components\ChoiceCards
State typestring|null — one option key
Model cast'plan' => 'string' or backed enum
FieldTypechoice_cards

Basic usage

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

ChoiceCards::make('plan')
    ->label('Select a plan')
    ->helperText('Choose the plan that suits your needs')
    ->options([
        'starter' => [
            'label' => 'Starter',
            'description' => 'For individuals',
            'price' => '$5',
            'price_suffix' => '/mo',
        ],
        'pro' => 'Pro',
    ])
    ->layout('stack')
    ->default('pro');

Validation

BehaviourDetail
Built-inRule::in(...) — value must be a key from options()
required()At least one option must be selected

Configuration API

options(array|Closure $options)

Option list. See Rich card option shape.
ChoiceCards::make('field_name')
    ->options([
        'option_1' => 'Option 1',
        'option_2' => 'Option 2',
    ]);

disabledOptions(array|Closure $keys)

Disables options by key. Merged with per-option disabled.
ChoiceCards::make('field_name')
    ->disabledOptions(['option_2']);

layout(string|Closure $layout)

ValueDescription
stackVertical list of cards. Default.
gridResponsive column grid. Use with gridColumns().
mediaHorizontal row: icon + text. Best for icon-led options.
featuredPlan-style cards: icon box, badge, large price.
ChoiceCards::make('field_name')
    ->layout('value');

gridColumns(int|array|Closure $columns)

Column count for grid and multi-column media layouts.
->gridColumns(3)

->gridColumns([
    'default' => 1,
    'sm' => 2,
    'md' => 3,
    'lg' => 4,
])
Breakpoints cascade upward (smmdlg). Maximum: 4 columns.

indicator(string|Closure|null $indicator)

Selection marker in the top-right corner.
ValueDescription
radioRadio dot. Default for stack.
checkFilled circle with checkmark. Default for featured.
noneBorder-only selection. Default for media.
When omitted, the default is resolved from layout().
ChoiceCards::make('field_name')
    ->indicator('value');

variant(string|Closure $variant)

ValueDescription
defaultStandard grey card background.
primaryStronger selected state (featured plans).
secondarySubtle grid styling.
ChoiceCards::make('field_name')
    ->variant('primary');

color(string|Closure|null $color)

Accent color for the selected border. Default: primary. Supports Filament color tokens (success, danger, etc.).
ChoiceCards::make('field_name')
    ->color('primary');

size(string|ControlSize|Closure $size)

Scales padding, typography, indicators, and icons. See Control size.
ChoiceCards::make('field_name')
    ->size('md');

ripple(bool|Closure $condition = true)

Enables a Material-style click ripple on each card.
ChoiceCards::make('field_name')
    ->ripple(true);

Animations

  • Smooth border and background transitions on select/deselect
  • Indicator scale animation for check / radio states
  • Respects prefers-reduced-motion

FlexField schema config

When built via FlexFieldFormBuilder:
Config keyMaps to
optionsoptions()
layoutlayout()
grid_columns / columnsgridColumns()
sizesize()
variantvariant()
colorcolor()
rippleripple()
indicatorindicator()
disabled_optionsdisabledOptions()