Skip to content

Conversation

@angus-mcritchie
Copy link
Contributor

Summary

This PR adds the ability to configure the default grid breakpoint used when passing integers to grid methods like columns(2), columnSpan(3), columnStart(2), columnOrder(1), and grid(3).

Previously, the breakpoint was hardcoded to 'lg'. Now users can:

  1. Configure via config/filament.php:

    'default_grid_breakpoint' => '2xl',
  2. Set programmatically (e.g., in a service provider):

    use Filament\Support\Facades\FilamentGrid;
    
    FilamentGrid::defaultBreakpoint('xl');

Changes

  • Added GridManager class to manage the default breakpoint
  • Added FilamentGrid facade for easy access
  • Updated all grid-related methods to use the configurable breakpoint
  • Added config option with documentation
  • Added tests for both config and programmatic approaches
  • Updated layouts documentation

Why?

Some applications need consistent grid behavior across different breakpoints. For example, an app optimized for large displays may want '2xl' as the default instead of 'lg'.

This is fully backward compatible - the default remains 'lg'.

Copilot AI review requested due to automatic review settings January 20, 2026 00:05
@github-project-automation github-project-automation bot moved this to Todo in Roadmap Jan 20, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds the ability to configure the default grid breakpoint used when passing integers to grid methods like columns(2), columnSpan(3), columnStart(2), columnOrder(1), and grid(3). Additionally, it includes an unrelated feature that adds a formComponent() method to SelectFilter.

Changes:

  • Introduced configurable default grid breakpoint via config file and programmatic API
  • Added GridManager class and FilamentGrid facade to manage breakpoint configuration
  • Updated all grid-related methods across traits to use the configurable breakpoint
  • Added formComponent() method to SelectFilter for custom component classes
  • Added comprehensive tests and documentation

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/support/src/Grid/GridManager.php New class to manage default grid breakpoint configuration
packages/support/src/Facades/FilamentGrid.php New facade for accessing GridManager functionality
packages/support/src/SupportServiceProvider.php Registers GridManager and updates macros to use configurable breakpoint
packages/support/config/filament.php Adds default_grid_breakpoint configuration option
packages/support/src/Concerns/CanSpanColumns.php Updates to use configurable breakpoint instead of hardcoded 'lg'
packages/support/src/Concerns/CanOrderColumns.php Updates to use configurable breakpoint instead of hardcoded 'lg'
packages/schemas/src/Concerns/HasColumns.php Updates to use configurable breakpoint instead of hardcoded 'lg'
packages/schemas/src/Components/Concerns/HasContainerGridLayout.php Updates to use configurable breakpoint instead of hardcoded 'lg'
packages/tables/src/Filters/SelectFilter.php Adds formComponent() method and property for custom select components
packages/tables/src/Filters/Filter.php Adds PHPDoc comment for existing formComponent property
tests/src/Forms/GridTest.php Adds tests for configurable breakpoint functionality
tests/src/Tables/Filters/SelectFilterTest.php Adds test for formComponent() method
packages/schemas/docs/02-layouts.md Documents the new breakpoint configuration feature
packages/tables/docs/03-filters/02-select.md Documents the new formComponent() method for SelectFilter
packages/tables/docs/03-filters/01-overview.md Documents the new formComponent() method for Filter

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +16 to +22
$this->defaultBreakpoint = $breakpoint;
}

public function getDefaultBreakpoint(): string
{
return $this->evaluate($this->defaultBreakpoint) ?? config('filament.default_grid_breakpoint', 'lg');
}
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The defaultBreakpoint() method and getDefaultBreakpoint() do not validate that the provided breakpoint is one of the valid Tailwind breakpoints ('sm', 'md', 'lg', 'xl', '2xl'). Invalid breakpoints could cause unexpected behavior or silent failures in the grid system. Consider adding validation to ensure only valid breakpoints are accepted.

Suggested change
$this->defaultBreakpoint = $breakpoint;
}
public function getDefaultBreakpoint(): string
{
return $this->evaluate($this->defaultBreakpoint) ?? config('filament.default_grid_breakpoint', 'lg');
}
if (is_string($breakpoint) && ! $this->isValidBreakpoint($breakpoint)) {
// Ignore invalid breakpoint values and fall back to the configured default.
$this->defaultBreakpoint = null;
return;
}
$this->defaultBreakpoint = $breakpoint;
}
public function getDefaultBreakpoint(): string
{
$evaluatedBreakpoint = $this->evaluate($this->defaultBreakpoint);
if (is_string($evaluatedBreakpoint) && $this->isValidBreakpoint($evaluatedBreakpoint)) {
return $evaluatedBreakpoint;
}
$default = config('filament.default_grid_breakpoint', 'lg');
return $this->isValidBreakpoint($default) ? $default : 'lg';
}
protected function isValidBreakpoint(string $breakpoint): bool
{
return in_array($breakpoint, ['sm', 'md', 'lg', 'xl', '2xl'], true);
}

Copilot uses AI. Check for mistakes.
Comment on lines +169 to +188
test('can configure default grid breakpoint via config', function (): void {
config()->set('filament.default_grid_breakpoint', '2xl');

$schema = Schema::make(Livewire::make())
->columns($columnsAt2xl = rand(1, 12));

expect($schema)
->getColumns('2xl')->toBe($columnsAt2xl);
});

test('can configure default grid breakpoint via `FilamentGrid::defaultBreakpoint()` method', function (): void {
FilamentGrid::defaultBreakpoint('xl');

$component = (new Component)
->container(Schema::make(Livewire::make()))
->columnSpan($spanAtXl = rand(1, 12));

expect($component)
->getColumnSpan('xl')->toBe($spanAtXl);
});
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests modify global state (config and GridManager) but don't clean up after themselves. Since GridManager is registered as a scoped service, changes made in one test could potentially affect subsequent tests. Consider adding cleanup logic (e.g., in an afterEach hook or using Pest's defer function) to reset the default breakpoint to 'lg' after each test to prevent test interference.

Copilot uses AI. Check for mistakes.
Comment on lines 325 to 333
/**
* @param class-string<Select> $component
*/
public function formComponent(string $component): static
{
$this->formComponent = $component;

return $this;
}
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The formComponent() method doesn't have a PHPDoc annotation to document its parameter type. For consistency with the Filter class (lines 11-13 of Filter.php) and better IDE support, consider adding a PHPDoc comment with the @param class-string<Select> $component annotation above this method.

Copilot uses AI. Check for mistakes.
Comment on lines 23 to 26
/**
* @var class-string<Select>
*/
protected string $formComponent = Select::class;
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR appears to contain two unrelated features: grid breakpoint configuration (mentioned in the title/description) and the formComponent() functionality for SelectFilter. These should be in separate pull requests to maintain clear version history and easier code review. The formComponent() feature appears to be unrelated to the grid breakpoint configuration that is the stated purpose of this PR.

Copilot uses AI. Check for mistakes.
@angus-mcritchie angus-mcritchie force-pushed the configurable-default-grid-breakpoint branch from a1e8584 to a6c1d2f Compare January 20, 2026 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant