Skip to content

Laravel Swap Component

Free · MIT

A toggle component that swaps between two visual states with optional rotation or flip animations.

A Swap built for the TALL stack — Blade, Livewire 3 & 4, Alpine.js and Tailwind CSS 4. Server-rendered by default, dark-mode ready, and WCAG-minded. Drop it in with a single Blade tag: <x-aura::swap>

Installation

composer require bluestarsystem/aura-ui

Usage

<x-aura::swap>
    <x-slot:on>
        <x-aura::icon name="sun" class="w-6 h-6" />
    </x-slot:on>
    <x-slot:off>
        <x-aura::icon name="moon" class="w-6 h-6" />
    </x-slot:off>
</x-aura::swap>

See the full API, props and live examples in the Swap documentation.

Overview

The <x-aura::swap> component toggles between two content states using named on and off slots. It supports optional rotation and flip transition effects. Use it for theme toggles, icon switches, like/unlike buttons, or any two-state visual swap.

Props

Prop Type Default Description
active bool false Initial toggle state. true shows the on slot, false shows the off slot.
rotate bool false Apply a rotation transition when toggling.
flip bool false Apply a flip transition when toggling.

Slots

Slot Description
on Content displayed when the swap is active (toggled on).
off Content displayed when the swap is inactive (toggled off).

See more examples and every variant in the Swap documentation.

Laravel-native
No JavaScript framework. Pure Blade, Livewire & Alpine.
Dark mode & themeable
Tailwind 4 CSS variables and a visual Theme Studio.
Accessible
WCAG 2.1 AA-minded, keyboard and ARIA support.