BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/100xui/morph-modal

Morph modal

100xui/morph-modal
FreeBlock

A reusable modal component that smoothly 'morphs' from the dimensions and position of its trigger element

Live preview

live · rendered by the registry
Rendered by 100xui on their own page — this is the component running, not a screenshot of it.

Install it

npx shadcn@latest add https://100xui.com/r/morph-modal.json

Source

registry/100xui/blocks/morph-modal/components/morph-modal.tsx100xui.com/r/morph-modal.json
1"use client";
2
3import React from "react";
4import {
5 AnimatePresence,
6 motion,
7 type HTMLMotionProps,
8 type Transition,
9} from "motion/react";
10import { cn } from "@/lib/utils";
11
12function assertOnlyChild(children: React.ReactNode) {
13 if (Array.isArray(children))
14 throw new Error(
15 "A single child is required, but received multiple siblings."
16 );
17 if (
18 children &&
19 React.isValidElement(children) &&
20 children.type === React.Fragment &&
21 Array.isArray((children.props as React.FragmentProps).children)
22 )
23 throw new Error(
24 "A single child is required; fragments that render multiple siblings are not allowed."
25 );
26}
27
28type MorphModalContextType = {
29 openModal: boolean;
30 setOpenModal: React.Dispatch<React.SetStateAction<boolean>>;
31 modalId: string;
32 transition: Transition;
33};
34
35const MorphModalContext = React.createContext<
36 MorphModalContextType | undefined
37>(undefined);
38
39export const useMorphModal = () => {
40 const ctx = React.useContext(MorphModalContext);
41 if (!ctx)
42 throw new Error("useMorphModal must be used within a <MorphModal />");
43 return ctx;
44};
45
46interface MorphModalProps {
47 children: React.ReactNode;
48 transition?: Omit<Transition, "delay">;
49}
50
51const DEFAULT_DURATION = 0.3;
52const DEFAULT_EASE = "easeInOut";
53
54export function MorphModal({ children, transition }: MorphModalProps) {
55 const modalId = React.useId();
56 const [openModal, setOpenModal] = React.useState(false);
57
58 return (
59 <MorphModalContext.Provider
60 value={{
61 openModal,
62 setOpenModal,
63 modalId,
64 transition: {
65 duration: DEFAULT_DURATION,
66 ease: DEFAULT_EASE,
67 ...transition,
68 },
69 }}
70 >
71 {children}
72 </MorphModalContext.Provider>
73 );
74}
75
76interface MorphModalTriggerProps extends HTMLMotionProps<"button"> {
77 children: React.ReactNode;
78}
79
80export function MorphModalTrigger({
81 children,
82 className,
83 onClick,
84 ...rest
85}: MorphModalTriggerProps) {
86 assertOnlyChild(children);
87
88 const { openModal, setOpenModal, transition, modalId } = useMorphModal();
89 const { duration, ...restTransition } = transition;
90
91 return (
92 <div className="relative">
93 <AnimatePresence initial={false}>
94 {!openModal && (
95 <motion.button
96 onClick={(e) => {
97 setOpenModal(true);
98 onClick?.(e);
99 }}
100// … truncated

What it pulls in

npm packages

  • motion

Files it writes

  • registry/100xui/blocks/morph-modal/components/morph-modal.tsx

Facts

Registry
100xui
Type
registry:block
Access
Free
Files written
1
Licence
the repository states none
First indexed
2026-08-04
Last confirmed
today

Go to the source

Docs on 100xui 100xui.com YashwantOstwal/100xUI on GitHub Raw registry item This item as JSON

More from 100xui

All 14 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Apple galleryapple-gallery100xuiBlocksFree1 dep
Chat bento cardchat-bento-card100xuiBlocksFree1 dep
demosdemos100xuiBlocksFreeno deps · 12 files
In-page navbarin-page-navbar100xuiBlocksFree1 dep · 2 files
internalsinternals100xuiBlocksFreeno deps · 4 files
iPhone 3D mockupiphone-3d-mockup100xuiBlocksFreeno deps
Menu wheelmenu-wheel100xuiBlocksFree1 dep
Motion Dockmotion-dock100xuiBlocksFree1 dep · 3 files
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex