Presence

Content that arrives and leaves instead of popping in and out. `Presence` keeps a block on the page for the moment it takes to leave, so a hint, a result or a "you got it" note fades away rather than vanishing. `Swap` trades one piece of content for the…

decorativeclientuiv1.0.0

Preview

Presence — live rendereffects-presence--default ↗

Rendered from the story the storybook (a11y) CI gate runs axe against — the preview can't show something that hasn't been verified.

Install

Two equivalent paths — the URL works in any shadcn-CLI setup; the alias works once you've registered @interlace in your components.json.

Via shadcn URL
npx shadcn@latest add https://ds.interlace.tools/r/presence.json
With the @interlace alias
npx shadcn@latest add @interlace/presence

History

This component is at v1.0.0, first shipped in @interlace/ui 2.0.0. The version is stamped as a banner into the file the install writes, so the copy in your tree says which one you have — compare it with the number above before deciding whether to re-run the install.

@interlace/ui 2.0.01 entry

  • Addedminor

    New Presence and Swap, for content that arrives and leaves instead of popping in and out. Presence keeps a block on the page while it leaves (show, effect fade / rise / scale / blur, appear, onExited); Swap trades one version of its content for the next when swapKey changes (a quiz question for the next one, one step for another): the old one leaves, then the new one arrives, never both at once. slide moves along the reading direction and flips in a right-to-left page. Leaving content is inert and hidden from assistive technology, and when it held the focus, Swap hands focus to the new content. Only opacity, transform and filter move, timed by the brand's --duration-* and --ease-* tokens when they play; under reduced motion content simply appears and goes.

Import

5 named exports — pull the parts you need.

Public API
import { Presence, PresenceEffect, Swap, SwapDirection, SwapEffect } from '@/components/ui/effects/presence';

API reference

Parsed from the type declarations in the source — the same file the install writes into your tree, so this table can't drift from the component you get.

PresenceProps

Also accepts every <div> attribute.

PropTypeDescription
show*booleanWhether the content is on the page. Turning it off plays the leave, then removes it.
effectPresenceEffectHow it arrives and leaves. Every effect fades; `rise` also lifts, `scale` grows, `blur` sharpens. @default 'fade'
appearbooleanPlay the arrival on the first render too, not only when `show` turns on later. @default false
onExited() => voidCalled once the content has left and is no longer rendered.
renderuseRender.RenderPropReplace the rendered element, e.g. `<section />` or `<li />`.

SwapProps

Also accepts every <div> attribute.

PropTypeDescription
swapKey*React.KeyNames the content now shown. When it changes, the old content leaves, then the new arrives.
effectSwapEffectHow the versions trade places. `slide` moves along the reading direction. @default 'fade'
directionSwapDirectionFor `slide`: `forward` (next, the default) arrives from the inline end; `back` from the inline start. @default 'forward'
renderuseRender.RenderPropReplace the rendered element, e.g. `<section />` or `<li />`.

Accessibility

Every story for this component is rendered headlessly and checked with axe-core (wcag2aa, wcag22aa, best-practice, ACT) on every PR. That gate has no continue-on-error, so what ships has zero known violations.

What follows is what static analysis can see. Axe cannot press a key and never sees an overlay open, so the operable-without-a-mouse claim lives in Behavior instead, where the keyboard path is replayed step by step.

Focus + keyboard behaviour
Owned by @base-ui/react/use-render — focus trapping, dismissal and typeahead come from the headless primitive, not from us.
Focus ring (WCAG 2.2 SC 2.4.13)
Not focusable — no focus indicator required.
Reduced motion
Animation is gated on prefers-reduced-motion.
ARIA in the source
None — semantics come from the element or the Base UI primitive rather than hand-written ARIA.

Examples

1 more state from the same story file.

R-rule compliance

Every primitive in @interlace/ui models to the portable 26-rule floor enforced by the componentApi ESLint preset. The cells below pin exactly where each rule applies in this file.

RuleConceptWhere
R4Extends native el`div` props
R6data-slot per partpresence / swap
R7cn + ...rest`cn(className)` + `{...props}` + `useRender`
R8Enums, not booleans`effect`, `direction`
R13Ecosystem first`useRender` to be the element itself
R19Tokens only`--duration-*`, `--ease-*` read at play time
R25Client componentplays in the browser
R26A11yleaving content is inert; focus follows a swap

Dependencies

Base UI primitive
@base-ui/react/use-render
Lucide icons
none
NPM dependencies
  • @base-ui/react

Source

The full implementation — components/ui/effects/presence.tsx once installed.

383 lines · TypeScript
'use client';

import { useRender } from '@base-ui/react/use-render';

// @interlace/presence v1.0.0 — Interlace design system.
// Docs, props and live preview: https://ds.interlace.tools/c/presence
// What changed since: https://ds.interlace.tools/c/presence#history
// Generated banner — keep it, the upgrade diff reads this version.

/**
 * @interlace/ui — Presence and Swap
 *
 * Content that arrives and leaves instead of popping in and out. `Presence`
 * keeps a block on the page for the moment it takes to leave, so a hint, a
 * result or a "you got it" note fades away rather than vanishing. `Swap` trades
 * one piece of content for the next (a quiz question for the following one,
 * one step for another, today's card for tomorrow's): the old one leaves,
 * then the new one arrives, so the reader sees that something changed and in
 * which direction.
 *

…363 more lines…

Registry JSON

The raw registry record — what the shadcn CLI fetches.