Rendyn

Component library

189 components

Interaction

Morphing Modal

Morphing Modal renders a selected viewId and asks the parent to close it.

Interactive exampleReact Tailwind CSS

Practical React example

Open a compact record preview and switch between named detail views without losing the active task.

Before you copy and paste

Keep the example in the React rendering environment required by the imported component. Copy components/motion/morphing-modal.tsx and its returned support files from the Code tab; preserve the project-relative paths.

Listed package dependencies: clsx, lucide-react, motion, react, tailwind-merge.

Use the Code tab for the component files and installation instructions, then adapt the imports in this example to your project.

Open a compact record preview and switch between named detail views without losing the active task

// Usage adapted from beUI's pinned MIT source.
// Copyright (c) 2026 Saurabh Chauhan. See ./LICENSES.md.
'use client';

import { useState } from 'react';
import { MorphingModal } from '@/components/motion/morphing-modal';

export function ProjectDetails() {
  const [view, setView] = useState<'summary' | 'notes' | null>(null);
  return (
    <section>
      <button type="button" onClick={() => setView('summary')}>Open project details</button>
      <MorphingModal viewId={view} onClose={() => setView(null)} placement="center">
        <div aria-labelledby="project-detail-heading" className="p-6">
          <h2 id="project-detail-heading">{view === 'notes' ? 'Project notes' : 'Project summary'}</h2>
          <p>{view === 'notes' ? 'Review the draft before publishing.' : 'A small workspace for the product launch.'}</p>
          <button type="button" onClick={() => setView(view === 'notes' ? 'summary' : 'notes')}>
            {view === 'notes' ? 'Show summary' : 'Show notes'}
          </button>
          <button type="button" onClick={() => setView(null)}>Close details</button>
        </div>
      </MorphingModal>
    </section>
  );
}

Usage example adapted from beUI's pinned MIT source. Retain the source licence notices when copying.

Keep viewId aligned with the child view you render; use null for the closed state. Save data through your application before treating a view transition as success.

Customization

MorphingModalProps.viewId
Required; string | null. Which view is currently shown. `null` closes the modal.
MorphingModalProps.onClose
Required; () => void.
MorphingModalProps.children
Required; ReactNode.
MorphingModalProps.placement
Optional; "bottom" | "center". "bottom" anchors to the viewport bottom (mobile-like). "center" centers vertically.
MorphingModalProps.className
Optional; string.
PresenceGateRenderProps.isPresent
Required; boolean. False from the render that starts the exit animation onward. An overlay kept in the tree by `AnimatePresence` is still the topmost thing on the page, so anything it decides from `open` alone stays true for the whole exit — this is the boolean that already knows the overlay is leaving.
PresenceGateRenderProps.gate
Required; { inert: boolean; style: { pointerEvents: "auto" | "none" }; }. Spread onto every layer that takes pointer events while the overlay is open. Interaction releases in the same commit that starts the exit while the visual exit keeps playing: pointer events stop landing, and `inert` drops the subtree from focus order, from tab order and from the accessibility tree — an exiting dialog is not a dialog you can still type into. A layer that never takes pointer events (a wrapper that only centres the panel) takes `inert={!isPresent}` alone, so its own `pointer-events-none` is not overwritten.
PresenceGateProps.children
Required; (props: PresenceGateRenderProps) => ReactNode.

Integration notes

  • Preserve a clear accessible name and a visible way to close the modal.
  • Check focus return and unsaved edits when the selected record changes.

Component source: beUI documentation . These examples describe the version imported into Rendyn. Upstream APIs may have changed; retain the source licence notices when adapting the code.

Better with your agent

Give your agent taste.

The best way to use Rendyn is through MCP. Let your agent find the right component, compare previews and bring the source into your project.

All components are free. Sign up only to connect MCP.

Connect to MCP