Skip to content
daisyBlazor

Swap

Toggles between two pieces of content, On and Off, with an optional rotate or flip animation. Bind Active for two-way state.
Actions.swap
Cover · <Swap>

Tap to deploy

Examples

Rotate

Animation="SwapAnimation.Rotate" spins between the icons; @bind-Active keeps your field in sync.

Light mode
website/Examples/Actions/SwapRotateExample.razor Source

Flip

SwapAnimation.Flip turns the content over like a card.

Sync paused
website/Examples/Actions/SwapFlipExample.razor Source

Text, no animation

On and Off take any markup; without an animation the switch is instant.

website/Examples/Actions/SwapTextExample.razor Source

API

<Swap>

DaisyBlazor

Parameters

  • Active bool
    = false

    Whether the swap is in the active (on) state.

  • Animation SwapAnimation
    = SwapAnimation.None

    Animation applied to the swap transition.

  • AriaLabel string
    = null

    Accessible name of the toggle, read by screen readers (the On/Off content is usually an icon).

  • Class string
    = null

    Extra CSS classes merged onto the swap label.

  • Style string
    = null

    Inline CSS styles applied to the swap label.

Events

  • ActiveChanged EventCallback<bool>

    Raised when the active state changes.

Content

  • Off RenderFragment

    Content shown when the swap is inactive (unchecked).

  • On RenderFragment

    Content shown when the swap is active (checked).

Something went wrong while running the docs. Reload