Skip to content

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

Open
ashraful19 wants to merge 4 commits into
filamentphp:4.xfrom
ashraful19:feat/panel-sidebar-width-closure
Open

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

Conversation

@ashraful19

Copy link
Copy Markdown

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request pending review

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants