Skip to content

Commit bbb17bb

Browse files
committed
Render loader via portal covering full viewport
1 parent c6c2734 commit bbb17bb

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/components/PageLoader.jsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1+
import { createPortal } from 'react-dom';
12
import { AnimatePresence, motion } from 'framer-motion';
23

34
export default function PageLoader({ show, label = 'Loading' }) {
4-
5-
return (
5+
return createPortal(
66
<AnimatePresence>
77
{show && (
88
<motion.div
9-
className="fixed inset-0 z-[60] flex flex-col items-center justify-center bg-slate-950"
9+
className="fixed inset-0 z-[9999] flex flex-col items-center justify-center bg-slate-950"
1010
initial={{ opacity: 0 }}
1111
animate={{ opacity: 1 }}
1212
exit={{ opacity: 0 }}
@@ -32,6 +32,7 @@ export default function PageLoader({ show, label = 'Loading' }) {
3232
</motion.div>
3333
</motion.div>
3434
)}
35-
</AnimatePresence>
35+
</AnimatePresence>,
36+
document.body
3637
);
3738
}

0 commit comments

Comments
 (0)