Swap
Swap toggles the visibility of two elements using a checkbox, with optional rotate or flip animation. Built with Swap.On, Swap.Off, and optional Swap.Indeterminate sub-components.
Import
import { Swap } from '@sigx/daisyui';
Basic Text Swap
Toggle between two text labels.
Loading preview...
Rotate Effect
Apply a rotation animation during the swap transition.
Loading preview...
Flip Effect
Apply a 3D flip animation during the swap transition.
Loading preview...
Hamburger Button
Combine Swap with button classes for a hamburger menu toggle.
Loading preview...
Active (Class-based)
Use the active prop to control the swap state without a checkbox interaction.
Loading preview...
Volume Icons
Swap between volume on and off icons with rotation.
Loading preview...
With Indeterminate State
The Swap.Indeterminate sub-component renders content visible when the checkbox is in an indeterminate state.
Loading preview...
Props
Swap
| Prop | Type | Default | Description |
|---|---|---|---|
rotate | boolean | false | Apply rotation animation effect |
flip | boolean | false | Apply 3D flip animation effect |
active | boolean | false | Activate swap display via class (no checkbox needed) |
model | Signal<boolean> | undefined | Two-way binding for controlled state |
class | string | undefined | Additional CSS classes |
onChange | (checked: boolean) => void | undefined | Callback when swap state changes |
Swap.On
| Prop | Type | Default | Description |
|---|---|---|---|
class | string | undefined | Additional CSS classes for the on-state element |
Swap.Off
| Prop | Type | Default | Description |
|---|---|---|---|
class | string | undefined | Additional CSS classes for the off-state element |
Swap.Indeterminate
| Prop | Type | Default | Description |
|---|---|---|---|
class | string | undefined | Additional CSS classes for the indeterminate-state element |