diff --git a/apps/v4/content/docs/components/base/drawer.mdx b/apps/v4/content/docs/components/base/drawer.mdx index 762642e179d..40d8f62c30d 100644 --- a/apps/v4/content/docs/components/base/drawer.mdx +++ b/apps/v4/content/docs/components/base/drawer.mdx @@ -4,15 +4,12 @@ description: A drawer component for React. base: base component: true links: - doc: https://vaul.emilkowal.ski/getting-started + doc: https://base-ui.com/react/components/drawer + api: https://base-ui.com/react/components/drawer#api-reference --- -## About - -Drawer is built on top of [Vaul](https://github.com/emilkowalski/vaul) by [emilkowalski](https://twitter.com/emilkowalski). - ## Installation @@ -36,7 +33,7 @@ npx shadcn@latest add drawer Install the following dependencies: ```bash -npm install vaul +npm install @base-ui/react ``` Copy and paste the following code into your project. @@ -65,6 +62,8 @@ import { DrawerDescription, DrawerFooter, DrawerHeader, + DrawerPopup, + DrawerSwipeArea, DrawerTitle, DrawerTrigger, } from "@/components/ui/drawer" @@ -72,19 +71,19 @@ import { ```tsx showLineNumbers - Open - - - Are you absolutely sure? - This action cannot be undone. - - - - - - - - + Open} /> + + + + Are you absolutely sure? + This action cannot be undone. + + + + Cancel} /> + + + ``` @@ -98,7 +97,7 @@ Keep actions visible while the content scrolls. ### Sides -Use the `direction` prop to set the side of the drawer. Available options are `top`, `right`, `bottom`, and `left`. +Use the `swipeDirection` prop to set the side of the drawer. Available options are `up`, `right`, `down`, and `left`. @@ -116,4 +115,4 @@ To enable RTL support in shadcn/ui, see the [RTL configuration guide](/docs/rtl) ## API Reference -See the [Vaul documentation](https://vaul.emilkowal.ski/getting-started) for the full API reference. +See the [Base UI documentation](https://base-ui.com/react/components/drawer#api-reference) for the full API reference. diff --git a/apps/v4/examples/base/drawer-demo.tsx b/apps/v4/examples/base/drawer-demo.tsx index ab8c129adc4..62f56013758 100644 --- a/apps/v4/examples/base/drawer-demo.tsx +++ b/apps/v4/examples/base/drawer-demo.tsx @@ -12,6 +12,7 @@ import { DrawerDescription, DrawerFooter, DrawerHeader, + DrawerPopup, DrawerTitle, DrawerTrigger, } from "@/styles/base-nova/ui/drawer" @@ -67,69 +68,69 @@ export function DrawerDemo() { return ( - - - - -
- - Move Goal - Set your daily activity goal. - -
-
- -
-
- {goal} -
-
- Calories/day + Open Drawer} /> + + +
+ + Move Goal + + Set your daily activity goal. + + +
+
+ +
+
+ {goal} +
+
+ Calories/day +
+ +
+
+ + + + +
- -
-
- - - - -
+ + + Cancel} /> +
- - - - - - -
- + + ) } diff --git a/apps/v4/examples/base/drawer-dialog.tsx b/apps/v4/examples/base/drawer-dialog.tsx index 9512ddd647b..cbbcd81595f 100644 --- a/apps/v4/examples/base/drawer-dialog.tsx +++ b/apps/v4/examples/base/drawer-dialog.tsx @@ -20,6 +20,7 @@ import { DrawerDescription, DrawerFooter, DrawerHeader, + DrawerPopup, DrawerTitle, DrawerTrigger, } from "@/styles/base-nova/ui/drawer" @@ -52,23 +53,22 @@ export function DrawerDialogDemo() { return ( - - - - - - Edit profile - - Make changes to your profile here. Click save when you're done. - - - - - - - - - + Edit Profile} /> + + + + Edit profile + + Make changes to your profile here. Click save when you're + done. + + + + + Cancel} /> + + + ) } diff --git a/apps/v4/examples/base/drawer-rtl.tsx b/apps/v4/examples/base/drawer-rtl.tsx index 23a3a3cc379..071baf069bb 100644 --- a/apps/v4/examples/base/drawer-rtl.tsx +++ b/apps/v4/examples/base/drawer-rtl.tsx @@ -16,6 +16,7 @@ import { DrawerDescription, DrawerFooter, DrawerHeader, + DrawerPopup, DrawerTitle, DrawerTrigger, } from "@/styles/base-nova/ui-rtl/drawer" @@ -117,77 +118,77 @@ export function DrawerRtl() { return ( - - - - -
- - {t.title} - {t.description} - -
-
- -
-
- {goal.toLocaleString(locale)} -
-
- {t.caloriesPerDay} + {t.trigger}} /> + + +
+ + {t.title} + {t.description} + +
+
+ +
+
+ {goal.toLocaleString(locale)} +
+
+ {t.caloriesPerDay} +
+ +
+
+ + + value.toLocaleString(locale)} + reversed={dir === "rtl"} + /> + + +
- -
-
- - - value.toLocaleString(locale)} - reversed={dir === "rtl"} - /> - - -
+ + + {t.cancel}} + /> +
- - - - - - -
- + + ) } diff --git a/apps/v4/examples/base/drawer-scrollable-content.tsx b/apps/v4/examples/base/drawer-scrollable-content.tsx index e005c83ac1f..af54c0c4f24 100644 --- a/apps/v4/examples/base/drawer-scrollable-content.tsx +++ b/apps/v4/examples/base/drawer-scrollable-content.tsx @@ -6,41 +6,42 @@ import { DrawerDescription, DrawerFooter, DrawerHeader, + DrawerPopup, DrawerTitle, DrawerTrigger, } from "@/styles/base-nova/ui/drawer" export function DrawerScrollableContent() { return ( - - - - - - - Move Goal - Set your daily activity goal. - -
- {Array.from({ length: 10 }).map((_, index) => ( -

- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do - eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut - enim ad minim veniam, quis nostrud exercitation ullamco laboris - nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in - reprehenderit in voluptate velit esse cillum dolore eu fugiat - nulla pariatur. Excepteur sint occaecat cupidatat non proident, - sunt in culpa qui officia deserunt mollit anim id est laborum. -

- ))} -
- - - - - - -
+ + Scrollable Content} + /> + + + + Move Goal + Set your daily activity goal. + +
+ {Array.from({ length: 10 }).map((_, index) => ( +

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do + eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut + enim ad minim veniam, quis nostrud exercitation ullamco laboris + nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor + in reprehenderit in voluptate velit esse cillum dolore eu fugiat + nulla pariatur. Excepteur sint occaecat cupidatat non proident, + sunt in culpa qui officia deserunt mollit anim id est laborum. +

+ ))} +
+ + + Cancel} /> + +
+
) } diff --git a/apps/v4/examples/base/drawer-sides.tsx b/apps/v4/examples/base/drawer-sides.tsx index 6b26bd27f90..79a2066f1df 100644 --- a/apps/v4/examples/base/drawer-sides.tsx +++ b/apps/v4/examples/base/drawer-sides.tsx @@ -6,11 +6,12 @@ import { DrawerDescription, DrawerFooter, DrawerHeader, + DrawerPopup, DrawerTitle, DrawerTrigger, } from "@/styles/base-nova/ui/drawer" -const DRAWER_SIDES = ["top", "right", "bottom", "left"] as const +const DRAWER_SIDES = ["up", "right", "down", "left"] as const export function DrawerWithSides() { return ( @@ -18,43 +19,47 @@ export function DrawerWithSides() { {DRAWER_SIDES.map((side) => ( - - - - - - Move Goal - - Set your daily activity goal. - - -
- {Array.from({ length: 10 }).map((_, index) => ( -

- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed - do eiusmod tempor incididunt ut labore et dolore magna aliqua. - Ut enim ad minim veniam, quis nostrud exercitation ullamco - laboris nisi ut aliquip ex ea commodo consequat. Duis aute - irure dolor in reprehenderit in voluptate velit esse cillum - dolore eu fugiat nulla pariatur. Excepteur sint occaecat - cupidatat non proident, sunt in culpa qui officia deserunt - mollit anim id est laborum. -

- ))} -
- - - - - - -
+ + {side} + + } + /> + + + + Move Goal + + Set your daily activity goal. + + +
+ {Array.from({ length: 10 }).map((_, index) => ( +

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed + do eiusmod tempor incididunt ut labore et dolore magna + aliqua. Ut enim ad minim veniam, quis nostrud exercitation + ullamco laboris nisi ut aliquip ex ea commodo consequat. + Duis aute irure dolor in reprehenderit in voluptate velit + esse cillum dolore eu fugiat nulla pariatur. Excepteur sint + occaecat cupidatat non proident, sunt in culpa qui officia + deserunt mollit anim id est laborum. +

+ ))} +
+ + + Cancel} + /> + +
+
))}
diff --git a/apps/v4/public/r/index.json b/apps/v4/public/r/index.json index 7d3fc8e7c08..4c2a82f7088 100644 --- a/apps/v4/public/r/index.json +++ b/apps/v4/public/r/index.json @@ -494,7 +494,7 @@ "base": { "docs": "https://ui.shadcn.com/docs/components/base/drawer", "examples": "https://raw.githubusercontent.com/shadcn-ui/ui/refs/heads/main/apps/v4/registry/bases/base/examples/drawer-example.tsx", - "api": "https://vaul.emilkowal.ski/getting-started" + "api": "https://base-ui.com/react/components/drawer.md" } } } diff --git a/apps/v4/public/r/styles/base-luma/drawer-example.json b/apps/v4/public/r/styles/base-luma/drawer-example.json index 3902cd4efb4..fa58ba7c67b 100644 --- a/apps/v4/public/r/styles/base-luma/drawer-example.json +++ b/apps/v4/public/r/styles/base-luma/drawer-example.json @@ -9,7 +9,7 @@ "files": [ { "path": "registry/base-luma/examples/drawer-example.tsx", - "content": "\"use client\"\n\nimport {\n Example,\n ExampleWrapper,\n} from \"@/registry/base-luma/components/example\"\nimport { Button } from \"@/registry/base-luma/ui/button\"\nimport {\n Drawer,\n DrawerClose,\n DrawerContent,\n DrawerDescription,\n DrawerFooter,\n DrawerHeader,\n DrawerTitle,\n DrawerTrigger,\n} from \"@/registry/base-luma/ui/drawer\"\n\nexport default function DrawerExample() {\n return (\n \n \n \n \n )\n}\n\nconst DRAWER_SIDES = [\"top\", \"right\", \"bottom\", \"left\"] as const\n\nfunction DrawerWithSides() {\n return (\n \n
\n {DRAWER_SIDES.map((side) => (\n \n \n \n \n \n \n Move Goal\n \n Set your daily activity goal.\n \n \n
\n {Array.from({ length: 10 }).map((_, index) => (\n \n Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed\n do eiusmod tempor incididunt ut labore et dolore magna\n aliqua. Ut enim ad minim veniam, quis nostrud exercitation\n ullamco laboris nisi ut aliquip ex ea commodo consequat.\n Duis aute irure dolor in reprehenderit in voluptate velit\n esse cillum dolore eu fugiat nulla pariatur. Excepteur sint\n occaecat cupidatat non proident, sunt in culpa qui officia\n deserunt mollit anim id est laborum.\n

\n ))}\n
\n \n \n \n \n \n \n
\n \n ))}\n
\n
\n )\n}\n\nfunction DrawerScrollableContent() {\n return (\n \n \n \n \n \n \n \n Move Goal\n Set your daily activity goal.\n \n
\n {Array.from({ length: 10 }).map((_, index) => (\n \n Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do\n eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut\n enim ad minim veniam, quis nostrud exercitation ullamco laboris\n nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor\n in reprehenderit in voluptate velit esse cillum dolore eu fugiat\n nulla pariatur. Excepteur sint occaecat cupidatat non proident,\n sunt in culpa qui officia deserunt mollit anim id est laborum.\n

\n ))}\n
\n \n \n \n \n \n \n
\n
\n
\n )\n}\n", + "content": "\"use client\"\n\nimport {\n Example,\n ExampleWrapper,\n} from \"@/registry/base-luma/components/example\"\nimport { Button } from \"@/registry/base-luma/ui/button\"\nimport {\n Drawer,\n DrawerClose,\n DrawerContent,\n DrawerDescription,\n DrawerFooter,\n DrawerHeader,\n DrawerPopup,\n DrawerTitle,\n DrawerTrigger,\n} from \"@/registry/base-luma/ui/drawer\"\n\nexport default function DrawerExample() {\n return (\n \n \n \n \n )\n}\n\nconst DRAWER_SIDES = [\"up\", \"right\", \"down\", \"left\"] as const\n\nfunction DrawerWithSides() {\n return (\n \n
\n {DRAWER_SIDES.map((side) => (\n \n \n {side}\n \n }\n />\n \n \n \n Move goal\n \n Set your daily activity goal.\n \n \n
\n {Array.from({ length: 10 }).map((_, index) => (\n

\n Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n Sed do eiusmod tempor incididunt ut labore et dolore magna\n aliqua. Ut enim ad minim veniam, quis nostrud exercitation\n ullamco laboris nisi ut aliquip ex ea commodo consequat.\n Duis aute irure dolor in reprehenderit in voluptate velit\n esse cillum dolore eu fugiat nulla pariatur. Excepteur\n sint occaecat cupidatat non proident, sunt in culpa qui\n officia deserunt mollit anim id est laborum.\n

\n ))}\n
\n \n \n Cancel}\n />\n \n
\n
\n \n ))}\n
\n
\n )\n}\n\nfunction DrawerScrollableContent() {\n return (\n \n \n Scrollable Content}\n />\n \n \n \n Move Goal\n \n Set your daily activity goal.\n \n \n
\n {Array.from({ length: 10 }).map((_, index) => (\n \n Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed\n do eiusmod tempor incididunt ut labore et dolore magna aliqua.\n Ut enim ad minim veniam, quis nostrud exercitation ullamco\n laboris nisi ut aliquip ex ea commodo consequat. Duis aute\n irure dolor in reprehenderit in voluptate velit esse cillum\n dolore eu fugiat nulla pariatur. Excepteur sint occaecat\n cupidatat non proident, sunt in culpa qui officia deserunt\n mollit anim id est laborum.\n

\n ))}\n
\n \n \n Cancel}\n >\n \n
\n
\n
\n
\n )\n}\n", "type": "registry:example" } ], diff --git a/apps/v4/public/r/styles/base-luma/drawer.json b/apps/v4/public/r/styles/base-luma/drawer.json index 7d645b84180..0f061bf8adb 100644 --- a/apps/v4/public/r/styles/base-luma/drawer.json +++ b/apps/v4/public/r/styles/base-luma/drawer.json @@ -2,12 +2,12 @@ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "drawer", "dependencies": [ - "vaul" + "@base-ui/react" ], "files": [ { "path": "registry/base-luma/ui/drawer.tsx", - "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { Drawer as DrawerPrimitive } from \"vaul\"\n\nimport { cn } from \"@/registry/base-luma/lib/utils\"\n\nfunction Drawer({\n ...props\n}: React.ComponentProps) {\n return \n}\n\nfunction DrawerTrigger({\n ...props\n}: React.ComponentProps) {\n return \n}\n\nfunction DrawerPortal({\n ...props\n}: React.ComponentProps) {\n return \n}\n\nfunction DrawerClose({\n ...props\n}: React.ComponentProps) {\n return \n}\n\nfunction DrawerOverlay({\n className,\n ...props\n}: React.ComponentProps) {\n return (\n \n )\n}\n\nfunction DrawerContent({\n className,\n children,\n ...props\n}: React.ComponentProps) {\n return (\n \n \n \n