Toggle Sidebar B
AppearanceLight & dark mode D

Pixel Swap

Pixel fragments assemble into a full cover, swap arbitrary content, then dissolve away with reversible colors and triggers.

Default

Hover or click the card to swap its content. Pattern, trigger and every timing prop are wired to the controls underneath.

Dark previewReplay previewOpen in new tab
Hover the card

Use UI Library

Customize

Pattern
Trigger
Pixel Size64px
Gap0px
Pixel Radius0%
Pixel Scale0.35
Pixel Spin0°
Duration1400ms
Pixel Duration450ms
Randomness0

API Reference

PixelSwap

PropTypeDefaultDescription
pixelSizenumber64Square pixel edge length in pixels. Grown automatically when the grid would exceed 220 pixels.
gapnumber0Space between pixels in pixels.
pixelRadiusnumber0Corner rounding of each pixel as a percentage (0 = square, 50 = circle).
pixelScalenumber0.35Size each pixel starts at, relative to its final size.
fadebooleantrueFade each pixel in as it opens. Disable for a hard pixel pop.
durationnumber1400Total transition duration in milliseconds.
pixelDurationnumber450Time a single pixel takes to open, in milliseconds.
pattern"random" | "center" | "edges" | "left-to-right" | "right-to-left" | "top-to-bottom" | "bottom-to-top" | "diagonal" | "spiral"randomOrder in which pixels animate.
randomnessnumber0Noise mixed into the pattern order, from 0 (strict) to 1 (fully scattered).
pixelSpinnumber0Degrees each pixel rotates as it opens.
easingstringcubic-bezier(0.22, 1, 0.36, 1)Easing applied to each pixel as it opens.
trigger"hover" | "click" | "manual"hoverInteraction that requests a content swap.
initialActivebooleanfalseWhether the second content is initially visible.
activebooleanundefinedControlled active state. Use with trigger="manual" for external control.
aspectRatiostring16 / 10CSS aspect-ratio value for the wrapper.
EventDescription
active-changeEmitted with a boolean whenever an interaction requests a state change.
completeEmitted with a boolean once the incoming content is fully revealed.
SlotDescription
firstContent shown in the initial state.
secondContent revealed after the pixel cover.

Accessibility

Keyboard shortcuts and ARIA behavior.

Shortcut Description
TabFocuses the card. With the hover trigger, focus also swaps the content.
EnterSwaps the content when the trigger is click.
SpaceSwaps the content when the trigger is click.
  • The hidden layer is aria-hidden, so screen readers only read the content currently shown.
  • With prefers-reduced-motion the content swaps with no pixel animation.