CBWIRE offers a smooth way to show or hide elements on your webpage with the wire:transition directive. This feature enhances user experience by making elements transition in and out smoothly, rather than just popping into view.
Basic Usage
This interactive dashboard component demonstrates multiple wire:transition features including basic transitions, directional control, duration customization, and different effect types:
// wires/Dashboard.bxclassextends="cbwire.models.Component"{ data ={"showStats":false,"showNotifications":false,"showModal":false};functiontoggleStats(){data.showStats =!data.showStats;}functiontoggleNotifications(){data.showNotifications =!data.showNotifications;}functionshowModal(){data.showModal =true;}functioncloseModal(){data.showModal =false;}}
What wire:transition Does
When you add wire:transition to an element, CBWIRE automatically:
Fades in/out: Changes opacity from 0 to 100% (and vice versa)
Scales: Transforms from slightly smaller to full size by default
Smooths interactions: Makes show/hide operations feel polished instead of abrupt
Available Modifiers
You can customize transitions with these modifiers:
Combine modifiers as needed: wire:transition.opacity.out.duration.300ms
Troubleshooting
Transitions Not Working
If you're not seeing transition effects, it may be because Livewire is having trouble with DOM diffing. You can often fix this by adding wire:key to the same element that has wire:transition:
This helps Livewire properly track the element across updates and apply transitions correctly.
Limitations
Currently, wire:transition should be applied to a single conditional element and doesn't work as expected with a list of dynamic elements, like individual comments in a loop. This is due to the limitations of how transitions are handled in the underlying framework.
Use wire:transition for show/hide scenarios on single elements rather than complex list animations for the best results.