BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/nexvyn/mobile-drawer

Mobile Drawer

nexvyn/mobile-drawer
FreeComponent

A bottom-sheet drawer with swipe-to-dismiss, focus trap, and scroll lock.

Live preview

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

Install it

npx shadcn@latest add https://ui.nexvyn.dev/r/mobile-drawer.json

Source

components/ui/mobile-drawer.tsxui.nexvyn.dev/r/mobile-drawer.json · first 6 KB
1'use client'
2
3import {
4 forwardRef,
5 useCallback,
6 useEffect,
7 useId,
8 useRef,
9 useState,
10 type HTMLAttributes,
11 type ReactNode,
12} from 'react'
13import { createPortal } from 'react-dom'
14import {
15 AnimatePresence,
16 motion,
17 useMotionValue,
18 useReducedMotion,
19 useTransform,
20} from 'motion/react'
21import { cn } from '@/lib/utils'
22import { springs } from '@/lib/motion-tokens'
23import { useFocusTrap } from '@/lib/hooks/use-focus-trap'
24import { useMounted } from '@/hooks/use-mounted'
25
26export interface MobileDrawerProps extends HTMLAttributes<HTMLDivElement> {
27 open: boolean
28 onClose: () => void
29 children: ReactNode
30 triggerRef?: React.RefObject<HTMLElement | null>
31 dismissible?: boolean
32}
33
34export interface MobileDrawerTitleProps extends HTMLAttributes<HTMLHeadingElement> {
35 children: ReactNode
36}
37
38export const MobileDrawerTitle = forwardRef<HTMLHeadingElement, MobileDrawerTitleProps>(
39 ({ children, className, ...props }, ref) => (
40 <h2
41 ref={ref}
42 className={cn('px-6 pt-6 pb-2 text-lg font-semibold text-(--color-fg)', className)}
43 {...props}
44 >
45 {children}
46 </h2>
47 ),
48)
49MobileDrawerTitle.displayName = 'MobileDrawerTitle'
50
51export const MobileDrawer = forwardRef<HTMLDivElement, MobileDrawerProps>(
52 (
53 {
54 open,
55 onClose,
56 children,
57 triggerRef: triggerRefProp,
58 dismissible = true,
59 className,
60 ...props
61 },
62 ref,
63 ) => {
64 const reduceMotion = useReducedMotion()
65 const mounted = useMounted()
66 const panelRef = useRef<HTMLDivElement>(null)
67 const dialogRef = useRef<HTMLDivElement>(null)
68 const previousScrollRef = useRef<string>('')
69 const dragY = useMotionValue(0)
70 const overlayOpacity = useTransform(dragY, [0, 300], [0.8, 0])
71
72 const reactId = useId()
73 const titleId = `${reactId}-drawer-title`
74
75 useFocusTrap(dialogRef, open, triggerRefProp)
76
77 useEffect(() => {
78 if (!open) return
79 previousScrollRef.current = document.body.style.overflow
80 document.body.style.overflow = 'hidden'
81 return () => {
82 document.body.style.overflow = previousScrollRef.current
83 }
84 }, [open])
85
86 const handleDragEnd = useCallback(
87 (_: unknown, info: { offset: { y: number }; velocity: { y: number } }) => {
88 if (!dismissible) return
89 const panelHeight = panelRef.current?.offsetHeight ?? 300
90 const pastThreshold = info.offset.y > panelHeight * 0.3
91 const fastFlick = info.velocity.y > 500
92// … truncated

What it pulls in

npm packages

  • motion

Files it writes

  • components/ui/mobile-drawer.tsx
  • lib/hooks/use-focus-trap.ts

Facts

Registry
nexvyn
Type
registry:ui
Access
Free
Files written
2
Licence
MIT
First indexed
2026-08-03
Last confirmed
today

Go to the source

Docs on nexvyn ui.nexvyn.dev Nexvyn/Nexvyn-ui on GitHub Raw registry item This item as JSON

More from nexvyn

All 33 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
BadgebadgenexvynComponentsFree2 deps · 2 files
Bars Themebars-themenexvynComponentsFree1 dep · 3 files
Bounce Sidebarbounce-sidebarnexvynComponentsFree1 dep · 2 files
BreadcrumbsbreadcrumbsnexvynComponentsFree1 dep · 2 files
CheckboxcheckboxnexvynComponentsFree1 dep · 3 files
Clipboard Fieldclipboard-fieldnexvynComponentsFreeno deps · 2 files
Color Pickercolor-pickernexvynComponentsFreeno deps · 16 files
ComboboxcomboboxnexvynComponentsFree1 dep · 2 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