Skip to content
Effects Fancy Stable

Presence

.md

Mounts and unmounts content with a real entrance and exit through one direction-aware transition, tracking opening/open/closing state, marking the panel inert while it closes, and firing lifecycle callbacks

Available for Svelte 5, React, and Vue 3.

Preview

Installation

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

Usage

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

	let agreed = $state(false);
</script>

<div class="flex w-full flex-col gap-2 p-6">
	<Checkbox bind:checked={agreed}>I agree to the terms and conditions</Checkbox>

	<Presence open={!agreed} duration={200} exitDuration={150}>
		<p class="text-destructive text-sm">You must agree before continuing.</p>
	</Presence>
</div>

Examples

Basic Usage

Presets

Switch between the entrance/exit looks.

Props

PropTypeDefaultDescription
open *boolean-Whether the content is mounted and, once the entrance settles, visible
preset "fade" | "fade-up" | "fade-down" | "fade-left" | "fade-right" | "scale" | "blur" | "zoom""fade"The entrance/exit look
duration number300Entrance duration in ms
exitDuration number200Exit duration in ms — shorter than the entrance by default; leaving reads faster than arriving
delay number0Delay in ms before the entrance starts; applied to the exit too
distance number16Entrance travel distance in px for the four directional presets — the exit travels half as far
inert booleantrueWhether the panel is inert while closing (Svelte already does this natively for any transitioning element — false is an explicit opt-out)
onEnterEnd () => void-Fires once the entrance transition settles (onintroend)
onExitEnd () => void-Fires once the exit transition settles (onoutroend) — not guaranteed if the component is destroyed mid-exit
class string-Additional CSS classes, merged onto the root
ref HTMLDivElement | nullnullBindable reference to the root element — null while closed

Slots

SlotDescription
children Panel content