© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•4mo ago•
3 replies
wazkaz

Repeater open conditionally.

Is it possible to open a repeater conditionally? For example, when a modal form opens and it contains several repeater items that are collapsed by default — is there a way to have one repeater item open while the others remain collapsed? If yes, how?
Solution
Found a solution
->collapsed(function (Livewire $livewire, ?ComponentContainer $item): bool {
  // When creating, keep items expanded
  if ($livewire->mountedActionName === 'create') {
      return false;
  }
                        
  // For edit mode, check if this specific item is the clicked option
  if ($item) {
      // Get the raw state from the ComponentContainer
      $state = $item->getRawState();
      $isClickedOption = $state['is_clicked_option'] ?? false;
      
      // Expand the clicked option (return false), collapse others (return true)
      return !$isClickedOption;
  }
  
  // Default: collapse items in edit mode
  return true;
})
->collapsed(function (Livewire $livewire, ?ComponentContainer $item): bool {
  // When creating, keep items expanded
  if ($livewire->mountedActionName === 'create') {
      return false;
  }
                        
  // For edit mode, check if this specific item is the clicked option
  if ($item) {
      // Get the raw state from the ComponentContainer
      $state = $item->getRawState();
      $isClickedOption = $state['is_clicked_option'] ?? false;
      
      // Expand the clicked option (return false), collapse others (return true)
      return !$isClickedOption;
  }
  
  // Default: collapse items in edit mode
  return true;
})
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Repeater: How can I conditionally show/hide Delete button in Repeater?
FilamentFFilament / ❓┊help
2y ago
Repeater: show delete button on each line conditionally
FilamentFFilament / ❓┊help
3y ago
Conditionally display either checkbox or radio button in Repeater
FilamentFFilament / ❓┊help
7mo ago
Add + button next to select button in repeater conditionally
FilamentFFilament / ❓┊help
2y ago