Skip to content
Cojeev UI

Presence

Effects

MotionPresence keeps keyed children mounted for their exits. MotionSurface adds coordinated lifecycle states to an existing primitive.

React · copy into your project · light and dark themes

Try it

Loading preview…

Take it with you

Copy the example, API and usage notes for your editor or AI assistant.

Add to your project

Terminal
npx shadcn@latest add https://luv-jeri.github.io/cojeev-ui/r/presence.json

The command includes the component’s shared dependencies. Your project keeps editable source files.

Include the complete example

This example also composes button, card, typography. Install its parts together:

Terminal
npx shadcn@latest add https://luv-jeri.github.io/cojeev-ui/r/button.json https://luv-jeri.github.io/cojeev-ui/r/card.json https://luv-jeri.github.io/cojeev-ui/r/typography.json https://luv-jeri.github.io/cojeev-ui/r/presence.json

Using presence

  • Keep the MotionPresence boundary mounted and give changing children stable keys.

  • Use MotionSurface asChild around exactly one ref-capable primitive.

  • Use quiet motion to settle immediately; the shared preference is inherited.

  • Use settle for a small scale-down exit, soften for upward blurred words, or focus for whole-phrase focus changes. These use a gentle 420ms default exit; existing presets keep their earlier timings.

  • Set exitDelay on sibling words for a departure sequence; it is capped at 600ms. exitDuration is seconds, bounded to 0–2. The caller controls removal, rather than a video timeline disappearing live content.

  • For staggered words, a keyed conditional heading inside MotionPresence may contain MotionSurface asChild spans. Keep a single accessible heading label and hide the animated fragments. Soft-focus presets own CSS filter; use a separate wrapper if the child already has an authored filter.

  • Directional blur can be composed with MotionSurface preset="soften": provide signed x or y and a blur in initial/exit, then zero x/y and blur in animate. Keep it inside MotionPresence for real removal; no separate wrapper primitive is needed.

API

Compose the exported parts below. The prop types are read from the React source during the registry build.

Native element or underlying primitive props are inherited where declared, including accessible labels, event handlers and refs.

MotionPresenceProps

Accepts the native or primitive props declared by its exported TypeScript type.

MotionSurfaceProps

PropTypeRequired
data-slotstringNo
asChild

Merge onto exactly one ref-capable child, preserving its native element.

booleanNo
presetPresencePresetNo
delay

Seconds; use motionTokens.stagger for a coordinated sibling sequence.

numberNo
exitDelay

Seconds before exit; cap sibling staggering yourself to a short total window.

numberNo
exitDuration

Seconds. Soft-focus and settling presets use a gentler 420ms default.

numberNo

Accessibility

  • Preserve native semantics with asChild.

  • Put presence outside the actual conditional removal; an inner boundary cannot retain its own parent.

  • Exiting surfaces are inert and hidden from assistive technology until removed; quiet preferences remove the delay and motion.

States and appearance

enteringvisibleexitingremovedreduced-motion

For conditional content, keep a MotionPresence boundary around keyed MotionSurface children. The shared entrance and exit states work with native primitives and respect your motion preference.

Try pointer and keyboard interaction, and switch the appearance control in the navigation to compare light and dark mode. Motion respects reduced motion preferences.