wire:transition

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.bx
class extends="cbwire.models.Component" {
    data = {
        "showStats": false,
        "showNotifications": false,
        "showModal": false
    };

    function toggleStats() {
        data.showStats = !data.showStats;
    }

    function toggleNotifications() {
        data.showNotifications = !data.showNotifications;
    }

    function showModal() {
        data.showModal = true;
    }

    function closeModal() {
        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:

  • Directional: .in (appear only), .out (disappear only)

  • Duration: .duration.[?ms] (e.g., .duration.300ms)

  • Effects: .opacity (fade only), .scale (scale only)

  • Origins: .origin.top|bottom|left|right (scale origin point)

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.

Was this helpful?