Skip to content

Add Closure support to sidebarWidth() and collapsedSidebarWidth()#20009

Merged
danharrin merged 6 commits into
filamentphp:4.xfrom
ashraful19:feat/panel-sidebar-width-closure
Jul 8, 2026
Merged

Add Closure support to sidebarWidth() and collapsedSidebarWidth()#20009
danharrin merged 6 commits into
filamentphp:4.xfrom
ashraful19:feat/panel-sidebar-width-closure

Conversation

@ashraful19

Copy link
Copy Markdown
Contributor

Description

Makes sidebarWidth() and collapsedSidebarWidth() accept a Closure for dynamic evaluation (e.g., per-tenant/user sidebar sizing).

Changes

  • HasSidebar trait: $sidebarWidth and $collapsedSidebarWidth properties changed to string | Closure. Setters accept string | Closure. Getters use $this->evaluate().

Usage

$panel->sidebarWidth(fn (): string => auth()->user()?->prefersWideSidebar() ? '24rem' : '20rem');
$panel->collapsedSidebarWidth(fn (): string => auth()->user()?->isCollapsedSidebarEnabled() ? '4.5rem' : '3rem');

Follows the established Closure pattern from HasTopNavigation, HasSpaMode, HasTopbar.

@github-project-automation github-project-automation Bot moved this to Todo in Roadmap Jun 5, 2026
@danharrin danharrin added enhancement New feature or request pending review labels Jun 5, 2026
@danharrin danharrin added this to the v4 milestone Jun 5, 2026
@github-project-automation github-project-automation Bot moved this from Todo to In Progress in Roadmap Jul 3, 2026
@danharrin danharrin merged commit 977fd68 into filamentphp:4.x Jul 8, 2026
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Roadmap Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants