Skip to content
shadcn.io
shadcn.io is not affiliated with official shadcn/ui

Shadcn Swap for React and Tailwind

Animate between two visual states with smooth transitions.

Installation

bunx --bun shadcn@latest add https://kit.dev/r/swap.json

Usage

import { 
  Swap, 
  SwapIndicator
} from "@/registry/react/components/swap";
<Swap>
  <SwapIndicator type="on">
    <MoonIcon />
  </SwapIndicator>
  <SwapIndicator type="off">
    <SunIcon />
  </SwapIndicator>
</Swap>

Examples

Fade

Flip

Rotate

Scale

Blur

API Reference

Swap

PropTypeDefault
variant"fade" | "scale" | "flip" | "rotate" | "blur""fade"
swapboolean-
lazyMountbooleantrue
unmountOnExitbooleantrue
classNamestring-
asChildboolean-

SwapIndicator

PropTypeDefault
type'on' | 'off'required
classNamestring-
asChildboolean-

For a complete list of props, see the Ark UI documentation.