Skip to content
Cards Fancy Stable

FlipCard

.md

Card that flips in 3D to reveal its back, on hover (plus focus and tap) or as a click toggle; it lifts and lands with a slight overshoot, keeps turning the way the pointer travels, and its faces catch a sweeping sheen and shade edge-on

Available for Svelte 5, React, and Vue 3.

Preview

Installation

pnpm add fancy-ui-svelte
import { FlipCard } from "fancy-ui-svelte";

Usage

svelte
<script lang="ts">
	import { FlipCard } from "fancy-ui-svelte";
</script>

<FlipCard>
	<div
		class="flex size-full items-center justify-center bg-gradient-to-br from-purple-500 to-pink-500"
	>
		<p class="text-2xl font-bold text-white">Front</p>
	</div>
	{#snippet back()}
		<div class="flex size-full flex-col items-center justify-center">
			<p class="text-lg font-semibold">Back Side</p>
			<p class="text-muted-foreground mt-2 text-sm">Hover, focus or tap to flip</p>
		</div>
	{/snippet}
</FlipCard>

Examples

Basic Usage

X-Axis Rotation

Flip vertically.

Click to Flip

A toggle: click, tap, Enter or Space. The link on the back stays clickable, and bind:flipped drives it from outside.

Multiple Cards

Props

PropTypeDefaultDescription
rotate "x" | "y""y"Axis of rotation for the flip effect
trigger "hover" | "click""hover"Hover flips on pointer hover, keyboard focus and tap; click makes the card a toggle button (click, tap, Enter, Space)
flipped booleanfalseWhether the back is showing. Bindable
onflip (flipped: boolean) => void-Called with the new state after every flip
duration number700Length of one flip in milliseconds
glare booleantrueLight the faces as they turn: a sweeping sheen and an edge-on shade
label string-Accessible name for the card
class string-Additional classes; size the card here (default h-72 w-56)

Slots

SlotDescription
children Front face content
back Back face content