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…
Preview
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.
npx shadcn@latest add https://ds.interlace.tools/r/presence.jsonnpx shadcn@latest add @interlace/presenceHistory
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.
Presencekeeps a block on the page while it leaves (show,effectfade / rise / scale / blur,appear,onExited);Swaptrades one version of its content for the next whenswapKeychanges (a quiz question for the next one, one step for another): the old one leaves, then the new one arrives, never both at once.slidemoves along the reading direction and flips in a right-to-left page. Leaving content isinertand hidden from assistive technology, and when it held the focus, Swap hands focus to the new content. Onlyopacity,transformandfiltermove, 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.
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.
| Prop | Type | Description |
|---|---|---|
| show* | boolean | Whether the content is on the page. Turning it off plays the leave, then removes it. |
| effect | PresenceEffect | How it arrives and leaves. Every effect fades; `rise` also lifts, `scale` grows, `blur` sharpens. @default 'fade' |
| appear | boolean | Play the arrival on the first render too, not only when `show` turns on later. @default false |
| onExited | () => void | Called once the content has left and is no longer rendered. |
| render | useRender.RenderProp | Replace the rendered element, e.g. `<section />` or `<li />`. |
SwapProps
Also accepts every <div> attribute.
| Prop | Type | Description |
|---|---|---|
| swapKey* | React.Key | Names the content now shown. When it changes, the old content leaves, then the new arrives. |
| effect | SwapEffect | How the versions trade places. `slide` moves along the reading direction. @default 'fade' |
| direction | SwapDirection | For `slide`: `forward` (next, the default) arrives from the inline end; `back` from the inline start. @default 'forward' |
| render | useRender.RenderProp | Replace 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.
| Rule | Concept | Where |
|---|---|---|
| R4 | Extends native el | `div` props |
| R6 | data-slot per part | presence / swap |
| R7 | cn + ...rest | `cn(className)` + `{...props}` + `useRender` |
| R8 | Enums, not booleans | `effect`, `direction` |
| R13 | Ecosystem first | `useRender` to be the element itself |
| R19 | Tokens only | `--duration-*`, `--ease-*` read at play time |
| R25 | Client component | plays in the browser |
| R26 | A11y | leaving 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.
'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.