InteractionKit

ViewTransition

A trigger that expands into a connected, non-modal surface.

Available in useintkit@0.0.1 and later.

Preview

Usage

view-transition.tsx
import "useintkit/styles.css";
import { ViewTransition } from "useintkit";

<ViewTransition trigger="Quick actions" size="md">
  {({ close }) => <button type="button" onClick={close}>Done</button>}
</ViewTransition>

Controlled state

Pass open and update it in onOpenChange. The render-prop close requests a state change; the parent remains responsible for applying it.

controlled.tsx
import { useState } from "react";
import { ViewTransition } from "useintkit";

function Details() {
  const [open, setOpen] = useState(false);
  return (
    <ViewTransition trigger="Details" open={open} onOpenChange={setOpen}>
      {({ close }) => <button type="button" onClick={close}>Close</button>}
    </ViewTransition>
  );
}

Appearance

The trigger fits its content by default; choose sm, md, or lg for the open width, or set a custom openWidth. Content scrolls above min(320px, 50vh). Use the class hooks or CSS variables to customize the surface, including that height limit.

styles.css
.my-transition {
  --ik-view-transition-radius: 16px;
  --ik-view-transition-padding: 12px;
  --ik-view-transition-max-height: 400px;
  --ik-view-transition-background: #fff;
  --ik-view-transition-color: #262626;
  --ik-view-transition-border: rgb(0 0 0 / 10%);
  --ik-view-transition-divider: rgb(0 0 0 / 6%);
  --ik-view-transition-shadow: 0 4px 12px rgb(0 0 0 / 8%);
}

.dark .my-transition {
  --ik-view-transition-background: #262626;
  --ik-view-transition-color: #f5f5f5;
  --ik-view-transition-border: rgb(255 255 255 / 10%);
  --ik-view-transition-divider: rgb(255 255 255 / 10%);
  --ik-view-transition-shadow: 0 4px 12px rgb(0 0 0 / 20%);
}

Apply the class with className="my-transition". The component stays in document flow, clips overflow, and does not position a popover or handle viewport collisions.

Props

PropTypeDescription
triggerReactNode | (open) => ReactNodeRequired content for the trigger button; do not nest interactive elements.
triggerLabelstringAccessible name for the trigger, required for an icon-only trigger.
childrenReactNode | ({ close }) => ReactNodeRequired content of the surface, optionally with a close callback.
open / onOpenChangeboolean / functionControl the open state from your application; update open when onOpenChange is called.
defaultOpenbooleanInitial uncontrolled state. Defaults to false.
size"sm" | "md" | "lg"Expanded width: 200, 240, or 320 pixels. Defaults to md.
closedWidth / openWidthnumberOptional pixel overrides; closed width otherwise fits the trigger, and openWidth overrides the size preset. Capped by available width.
springobjectOptional stiffness, damping and mass. Defaults to 700, 48 and 0.8.
contentDelaynumberContent entrance delay in seconds; defaults to 0.06.
closeOnOutsideClickbooleanDismiss on an outside pointer press; defaults to true.
className / triggerClassName / contentClassNamestringClasses for the surface, trigger and content.

This is a non-modal disclosure, not a menu or dialog. Its children remain mounted when closed but are inert and hidden from assistive technology. Escape closes it when focus is inside. It respects reduced motion; use Sheet for modal focus containment.