Skip to content

Morph Panel

A React button that morphs into the panel it opens on a spring, blurring the label out and the form in. Ships with a feedback form and closes on Escape.

src/registry/ui/morph-panel.tsx/r/morph-panel.json

Installation

bash
npx shadcn@latest add @minidev/morph-panel

MiniDev UI is in the shadcn registry directory, so the short form works with no setup. Older CLI versions can use the full URL: npx shadcn@latest add https://ui.minidev.pro/r/morph-panel.json

Usage

tsx
import { MorphPanel } from "@/components/ui/morph-panel"

export function Example() {
  return (
    <MorphPanel />
  )
}

API reference

MorphPanel props
PropTypeDefault
labelTrigger text; also the panel's accessible name when it is a string.React.ReactNode"Feedback"
iconIcon before the label.React.ReactNode<MessageSquareIcon />
widthPanel width in px.number340
anchorWhich corner of the trigger the panel grows from.Anchor"top-left"
openControlled open state.boolean-
defaultOpenInitial open state when uncontrolled.booleanfalse
onOpenChangeFires when the panel opens or closes.(open: boolean) => void-
childrenCustom panel as a render function. Receives close(), which also returns focus to the trigger.(api: { close: () => void }) => React.ReactNode-
onSubmitCalled with the text by the default feedback form. Return a promise to show "Sending…"; reject to let the user retry.(text: string) => void | Promise<void>-
classNamestring-

When to use

One surface grows from a pill into a panel, its corners easing from 10 to 16px, while the label blurs out and the content blurs in. No popover, no jump. Escape and an outside click close it and focus returns to the trigger; with reduced motion it swaps instantly. Default content is a feedback form with a sent state; pass a render function as children for your own panel. For a plain anchored panel use Popover; for a modal use Dialog.

Keyboard interactions

Keyboard interactions
KeyAction
EnterorSpaceOn the trigger, opens the panel.
EscapeCloses the panel and returns focus to the trigger.
MetaEnterorCtrlEnterIn the feedback textarea, sends the note.
TabMoves through the fields and buttons in the panel. Focus is not trapped.

Accessibility

  • The open panel has role="dialog" and an aria-label from label when it is a string, or "Panel" otherwise. It is not modal and has no aria-modal.
  • Escape returns focus to the trigger. An outside click closes it and leaves focus where the user clicked.
  • The textarea has aria-label="Feedback" and maxLength={500}. The "Sent" message renders inside an aria-live="polite" element that mounts together with its text, so some screen readers may not announce it.
  • Under reduced motion the pill and panel swap instantly.

Frequently asked questions

How do I put my own form inside MorphPanel?

Pass a render function as children: <MorphPanel label="New note" width={300}>{({ close }) => <NoteForm onDone={close} />}</MorphPanel>. Calling close() shuts the panel and returns focus to the trigger. Focus your first field yourself; only the built-in feedback form focuses its textarea on open.

How do I send the built-in feedback form to my API?

Pass onSubmit, which receives the text. Return a promise to show "Sending…"; if it rejects, the form goes back to idle so the user can retry, but no error message is shown. The panel closes itself 1.5s after the "Sent" state.

Can I open MorphPanel from outside, or control it?

Yes. Pass open and onOpenChange to control it, or defaultOpen for the first render. anchor picks the trigger corner the panel grows from, for example "bottom-right" for a button in the bottom-right of the screen.

How is it different from Popover or Dialog?

The trigger itself grows into the panel, and nothing else on the page is blocked. There is no focus trap and no backdrop. Use Popover for a panel anchored beside its trigger, and Dialog when the rest of the page must wait.

Dependencies

npm

lucide-reactmotion

Built from

No other MiniDev files

Examples

Feedback with an async submit

Return a promise from onSubmit (here a 900ms stand-in for your API call) to show "Sending…"; a rejected promise puts the form back so the user can retry.

Your own panel

Pass a render function; close() shuts the panel and returns focus to the trigger.

All Animated React components

Learn more