Morphing Tabs
Morphing Tabs accepts identified tab content and reports value, order and close changes.
Practical React example
Manage a small set of open document panels with optional reorder and close actions.
Before you copy and paste
Keep the example in the React rendering environment required by the imported component. Copy components/motion/morphing-tabs.tsx and its returned support files from the Code tab; preserve the project-relative paths.
Listed package dependencies: clsx, lucide-react, motion, react, react-dom, tailwind-merge.
Use the Code tab for the component files and installation instructions, then adapt the imports in this example to your project.
Manage a small set of open document panels with optional reorder and close actions
// Usage adapted from beUI's pinned MIT source.
// Copyright (c) 2026 Saurabh Chauhan. See ./LICENSES.md.
"use client";
import { useMemo, useState } from "react";
import { MorphingTabs, type MorphingTabsItem } from "@/components/motion/morphing-tabs";
const ROOM_CONTENT: Record<string, { eyebrow: string; title: string; detail: string; accent: string }> = {
"room-2": {
eyebrow: "quiet focus",
title: "Room 2",
detail: "A small space for the work that needs a little more air around it.",
accent: "#db5b2f",
},
general: {
eyebrow: "shared space",
title: "General",
detail: "The common room for notes, links and the ideas that are still finding their shape.",
accent: "#1bb273",
},
archive: {
eyebrow: "kept close",
title: "Archive",
detail: "Past rooms stay available without competing with the conversations in motion.",
accent: "#7a6de2",
},
};
function RoomPanel({ id }: { id: string }) {
const room = ROOM_CONTENT[id];
return (
<div className="relative min-h-64 overflow-hidden bg-[radial-gradient(circle_at_1px_1px,#dfe2e3_1px,transparent_1.5px)] bg-[size:4.8rem_4.8rem] px-7 py-8 md:px-12 md:py-10">
<div className="relative max-w-xl">
<p className="text-[0.68rem] font-semibold uppercase tracking-[0.24em] text-black/40">
{room.eyebrow}
</p>
<h3 className="mt-3 text-3xl font-light tracking-[-0.055em] text-[#151515] md:text-5xl">
{room.title}
</h3>
<p className="mt-4 max-w-md text-sm leading-6 text-black/55 md:text-base">
{room.detail}
</p>
<div className="mt-8 flex items-center gap-3 text-xs font-medium text-black/50">
<span className="size-2 rounded-full" style={{ backgroundColor: room.accent }} />
drag any room to reorder
</div>
</div>
</div>
);
}
export function MorphingTabsPreview() {
const initialItems = useMemo<MorphingTabsItem[]>(
() =>
Object.keys(ROOM_CONTENT).map((id) => ({
id,
label: ROOM_CONTENT[id].title,
content: <RoomPanel id={id} />,
})),
[],
);
const [items, setItems] = useState(initialItems);
const [value, setValue] = useState<string | null>("room-2");
return (
<div className="flex w-full min-w-0 items-center justify-center bg-[#242424] p-3 md:p-8">
<MorphingTabs
items={items}
value={value}
onValueChange={setValue}
onOrderChange={(ids) => {
setItems((current) => {
const byId = new Map(current.map((item) => [item.id, item]));
return ids.flatMap((id) => {
const item = byId.get(id);
return item ? [item] : [];
});
});
}}
onClose={(id) => {
setItems((current) => {
const next = current.filter((item) => item.id !== id);
if (id === value) setValue(next[0]?.id ?? null);
return next;
});
}}
ariaLabel="Rooms"
className="w-full max-w-5xl"
/>
</div>
);
}
Usage example adapted from beUI's pinned MIT source. Retain the source licence notices when copying.
Keep document IDs stable, persist order only when needed and handle an active tab being closed by selecting an adjacent valid tab.
Customization
- MorphingTabsProps.items
- Required; MorphingTabsItem[].
- MorphingTabsProps.value
- Optional; string | null.
- MorphingTabsProps.defaultValue
- Optional; string | null.
- MorphingTabsProps.onValueChange
- Optional; (id: string | null) => void.
- MorphingTabsProps.onOrderChange
- Optional; (ids: string[]) => void. Called once after a pointer drag or keyboard reorder completes.
- MorphingTabsProps.onClose
- Optional; (id: string) => void. Enables the close affordance on every tab when provided.
- MorphingTabsProps.ariaLabel
- Optional; string.
- MorphingTabsProps.className
- Optional; string.
- MorphingTabsProps.classNames
- Optional; MorphingTabsClassNames.
- SpringTabProps.id
- Required; string.
- SpringTabProps.targetLeft
- Required; number.
- SpringTabProps.dragging
- Required; boolean.
- SpringTabProps.dragLeft
- Required; MotionValue<number>.
- SpringTabProps.surfaceLeft
- Required; MotionValue<number>.
Integration notes
- Closing a tab should not silently discard unsaved edits.
- Keyboard reordering and close controls should remain usable without following the motion animation.
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.
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.