Tricks

Input group with combined fields

Apr 29, 2023
Chris
Form builder, Admin panel

With some CSS styling, you can easily transform a Filament Grid into an input group. screenshot

Add this to your CSS file - if you don't have one see how to register custom

@media (min-width: 1024px) {
.filament-input-group > .grid {
gap: 0;
}
 
.filament-input-group > .grid > :first-child .filament-forms-input,
.filament-input-group > .grid > :first-child .filament-forms-input .choices__inner {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
 
.filament-input-group > .grid > :not(:first-child):not(:last-child) .filament-forms-input,
.filament-input-group > .grid > :not(:first-child):not(:last-child) .filament-forms-input .choices__inner {
border-radius: 0;
border-left: none;
}
 
.filament-input-group > .grid > :last-child .filament-forms-input,
.filament-input-group > .grid > :last-child .filament-forms-input .choices__inner {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
border-left: none;
}
}

Add a class filament-input-group to isolate the changes.

Forms\Components\Grid::make()
->columns(3)
->extraAttributes(['class' => 'filament-input-group'])
->schema([
Forms\Components\TextInput::make('first'),
Forms\Components\Select::make('second'),
Forms\Components\ColorPicker::make('third'),
]),
avatar

Hello! First of all, thank you very much for your contribution, and sorry for my terrible English. I've tried this trick in the current version, 3.3, but only the gap works; changes to the stylesheet borders don't. Is there any other way to do this or make it work?