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

Shadcn Presence for React and Tailwind

Animate components on mount and unmount.

Installation

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

Usage

import React from "react";
import { Presence } from "@/registry/react/components/presence";

const [visible, setVisible] = React.useState(false);

<Presence present={visible}>
  Content that animates in and out
</Presence>

Lazy

Setting lazyMount and unmountOnExit to true lazy mounts and unmounts the content.

It will remove the element from the DOM when it is not present.

<Presence lazyMount unmountOnExit {...}>
  {/** content */}
</Presence>

States

Presence automatically manages the attribute data-state to open and closed. This enables styling and animations based on visibility state.

<Presence present={true} /> // <div data-state="open" />
<Presence present={false} /> // <div data-state="closed" />

API Reference

Presence

PropTypeDefault
presentbooleanfalse
unmountOnExitbooleantrue
lazyMountbooleantrue
asChildbooleanfalse

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