Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions apps/v4/app/(app)/create/components/open-preset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,12 @@ export function OpenPreset({
if (isMobile) {
return (
<Drawer open={open} onOpenChange={handleOpenChange}>
<DrawerTrigger asChild>
<Button variant="outline" className={triggerClassName}>
{label}
</Button>
<DrawerTrigger
render={<Button variant="outline" className={triggerClassName} />}
>
{label}
</DrawerTrigger>

<DrawerContent className="dark rounded-t-2xl!">
<DrawerHeader>
<DrawerTitle className="text-xl">{PRESET_TITLE}</DrawerTitle>
Expand All @@ -127,10 +128,12 @@ export function OpenPreset({
<Button type="submit" className="h-10" disabled={!nextPreset}>
Open
</Button>
<DrawerClose asChild>
<Button variant="outline" type="button" className="h-10">
Cancel
</Button>
<DrawerClose
render={
<Button variant="outline" type="button" className="h-10" />
}
>
Cancel
</DrawerClose>
</DrawerFooter>
</form>
Expand Down
4 changes: 1 addition & 3 deletions apps/v4/components/directory-add-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,7 @@ export function DirectoryAddProvider({
</DrawerHeader>
<div className="px-4">{Content}</div>
<DrawerFooter>
<DrawerClose asChild>
<Button size="sm">Done</Button>
</DrawerClose>
<DrawerClose render={<Button size="sm" />}>Done</DrawerClose>
</DrawerFooter>
</DrawerContent>
</Drawer>
Expand Down
13 changes: 5 additions & 8 deletions apps/v4/content/docs/components/base/drawer.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
---

<ComponentPreview styleName="base-nova" name="drawer-demo" />

## About

Drawer is built on top of [Vaul](https://github.com/emilkowalski/vaul) by [emilkowalski](https://twitter.com/emilkowalski).

## Installation

<CodeTabs>
Expand All @@ -36,7 +33,7 @@ npx shadcn@latest add drawer
<Step>Install the following dependencies:</Step>

```bash
npm install vaul
npm install @base-ui/react
```

<Step>Copy and paste the following code into your project.</Step>
Expand Down Expand Up @@ -112,7 +109,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`.

<ComponentPreview styleName="base-nova" name="drawer-sides" />

Expand All @@ -130,4 +127,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) for the full API reference.
8 changes: 4 additions & 4 deletions apps/v4/examples/base/drawer-demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ export function DrawerDemo() {

return (
<Drawer>
<DrawerTrigger asChild>
<Button variant="outline">Open Drawer</Button>
<DrawerTrigger render={<Button variant="outline" />}>
Open Drawer
</DrawerTrigger>
<DrawerContent>
<div className="mx-auto w-full max-w-sm">
Expand Down Expand Up @@ -124,8 +124,8 @@ export function DrawerDemo() {
</div>
<DrawerFooter>
<Button>Submit</Button>
<DrawerClose asChild>
<Button variant="outline">Cancel</Button>
<DrawerClose render={<Button variant="outline" />}>
Cancel
</DrawerClose>
</DrawerFooter>
</div>
Expand Down
8 changes: 4 additions & 4 deletions apps/v4/examples/base/drawer-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export function DrawerDialogDemo() {

return (
<Drawer open={open} onOpenChange={setOpen}>
<DrawerTrigger asChild>
<Button variant="outline">Edit Profile</Button>
<DrawerTrigger render={<Button variant="outline" />}>
Edit Profile
</DrawerTrigger>
<DrawerContent>
<DrawerHeader className="text-left">
Expand All @@ -64,8 +64,8 @@ export function DrawerDialogDemo() {
</DrawerHeader>
<ProfileForm className="px-4" />
<DrawerFooter className="pt-2">
<DrawerClose asChild>
<Button variant="outline">Cancel</Button>
<DrawerClose render={<Button variant="outline" />}>
Cancel
</DrawerClose>
</DrawerFooter>
</DrawerContent>
Expand Down
8 changes: 4 additions & 4 deletions apps/v4/examples/base/drawer-rtl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ export function DrawerRtl() {

return (
<Drawer>
<DrawerTrigger asChild>
<Button variant="outline">{t.trigger}</Button>
<DrawerTrigger render={<Button variant="outline" />}>
{t.trigger}
</DrawerTrigger>
<DrawerContent dir={dir} data-lang={dir === "rtl" ? language : undefined}>
<div className="mx-auto w-full max-w-sm">
Expand Down Expand Up @@ -182,8 +182,8 @@ export function DrawerRtl() {
</div>
<DrawerFooter>
<Button>{t.submit}</Button>
<DrawerClose asChild>
<Button variant="outline">{t.cancel}</Button>
<DrawerClose render={<Button variant="outline" />}>
{t.cancel}
</DrawerClose>
</DrawerFooter>
</div>
Expand Down
10 changes: 5 additions & 5 deletions apps/v4/examples/base/drawer-scrollable-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import {

export function DrawerScrollableContent() {
return (
<Drawer direction="right">
<DrawerTrigger asChild>
<Button variant="outline">Scrollable Content</Button>
<Drawer swipeDirection="right">
<DrawerTrigger render={<Button variant="outline" />}>
Scrollable Content
</DrawerTrigger>
<DrawerContent>
<DrawerHeader>
Expand All @@ -36,8 +36,8 @@ export function DrawerScrollableContent() {
</div>
<DrawerFooter>
<Button>Submit</Button>
<DrawerClose asChild>
<Button variant="outline">Cancel</Button>
<DrawerClose render={<Button variant="outline" />}>
Cancel
</DrawerClose>
</DrawerFooter>
</DrawerContent>
Expand Down
20 changes: 10 additions & 10 deletions apps/v4/examples/base/drawer-sides.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@ import {
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 (
<div className="flex flex-wrap gap-2">
{DRAWER_SIDES.map((side) => (
<Drawer
key={side}
direction={
side === "bottom" ? undefined : (side as "top" | "right" | "left")
swipeDirection={
side === "down" ? undefined : (side as "up" | "right" | "left")
}
>
<DrawerTrigger asChild>
<Button variant="outline" className="capitalize">
{side}
</Button>
<DrawerTrigger
render={<Button variant="outline" className="capitalize" />}
>
{side}
</DrawerTrigger>
<DrawerContent className="data-[vaul-drawer-direction=bottom]:max-h-[50vh] data-[vaul-drawer-direction=top]:max-h-[50vh]">
<DrawerContent className="data-[swipe-direction=down]:max-h-[50vh] data-[swipe-direction=up]:max-h-[50vh]">
<DrawerHeader>
<DrawerTitle>Move Goal</DrawerTitle>
<DrawerDescription>
Expand All @@ -50,8 +50,8 @@ export function DrawerWithSides() {
</div>
<DrawerFooter>
<Button>Submit</Button>
<DrawerClose asChild>
<Button variant="outline">Cancel</Button>
<DrawerClose render={<Button variant="outline" />}>
Cancel
</DrawerClose>
</DrawerFooter>
</DrawerContent>
Expand Down
2 changes: 1 addition & 1 deletion apps/v4/public/r/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion apps/v4/public/r/styles/base-luma/dashboard-01.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/v4/public/r/styles/base-luma/drawer-example.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 <ExampleWrapper>\n <DrawerScrollableContent />\n <DrawerWithSides />\n </ExampleWrapper>\n )\n}\n\nconst DRAWER_SIDES = [\"top\", \"right\", \"bottom\", \"left\"] as const\n\nfunction DrawerWithSides() {\n return (\n <Example title=\"Sides\">\n <div className=\"flex flex-wrap gap-2\">\n {DRAWER_SIDES.map((side) => (\n <Drawer\n key={side}\n direction={\n side === \"bottom\" ? undefined : (side as \"top\" | \"right\" | \"left\")\n }\n >\n <DrawerTrigger asChild>\n <Button variant=\"outline\" className=\"capitalize\">\n {side}\n </Button>\n </DrawerTrigger>\n <DrawerContent className=\"data-[vaul-drawer-direction=bottom]:max-h-[50vh] data-[vaul-drawer-direction=top]:max-h-[50vh]\">\n <DrawerHeader>\n <DrawerTitle>Move Goal</DrawerTitle>\n <DrawerDescription>\n Set your daily activity goal.\n </DrawerDescription>\n </DrawerHeader>\n <div className=\"no-scrollbar overflow-y-auto px-4\">\n {Array.from({ length: 10 }).map((_, index) => (\n <p\n key={index}\n className=\"mb-4 leading-normal style-lyra:mb-2 style-lyra:leading-relaxed\"\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 </p>\n ))}\n </div>\n <DrawerFooter>\n <Button>Submit</Button>\n <DrawerClose asChild>\n <Button variant=\"outline\">Cancel</Button>\n </DrawerClose>\n </DrawerFooter>\n </DrawerContent>\n </Drawer>\n ))}\n </div>\n </Example>\n )\n}\n\nfunction DrawerScrollableContent() {\n return (\n <Example title=\"Scrollable Content\">\n <Drawer direction=\"right\">\n <DrawerTrigger asChild>\n <Button variant=\"outline\">Scrollable Content</Button>\n </DrawerTrigger>\n <DrawerContent>\n <DrawerHeader>\n <DrawerTitle>Move Goal</DrawerTitle>\n <DrawerDescription>Set your daily activity goal.</DrawerDescription>\n </DrawerHeader>\n <div className=\"no-scrollbar overflow-y-auto px-4\">\n {Array.from({ length: 10 }).map((_, index) => (\n <p\n key={index}\n className=\"mb-4 leading-normal style-lyra:mb-2 style-lyra:leading-relaxed\"\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 </p>\n ))}\n </div>\n <DrawerFooter>\n <Button>Submit</Button>\n <DrawerClose asChild>\n <Button variant=\"outline\">Cancel</Button>\n </DrawerClose>\n </DrawerFooter>\n </DrawerContent>\n </Drawer>\n </Example>\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 DrawerTitle,\n DrawerTrigger,\n} from \"@/registry/base-luma/ui/drawer\"\n\nexport default function DrawerExample() {\n return (\n <ExampleWrapper>\n <DrawerScrollableContent />\n <DrawerWithSides />\n </ExampleWrapper>\n )\n}\n\nconst DRAWER_SIDES = [\"up\", \"right\", \"down\", \"left\"] as const\n\nfunction DrawerWithSides() {\n return (\n <Example title=\"Sides\">\n <div className=\"flex flex-wrap gap-2\">\n {DRAWER_SIDES.map((side) => (\n <Drawer\n key={side}\n swipeDirection={\n side === \"down\" ? undefined : (side as \"up\" | \"right\" | \"left\")\n }\n >\n <DrawerTrigger\n render={<Button variant=\"outline\" className=\"capitalize\" />}\n >\n {side}\n </DrawerTrigger>\n <DrawerContent className=\"data-[swipe-direction=down]:max-h-[50vh] data-[swipe-direction=up]:max-h-[50vh]\">\n <DrawerHeader>\n <DrawerTitle>Move Goal</DrawerTitle>\n <DrawerDescription>\n Set your daily activity goal.\n </DrawerDescription>\n </DrawerHeader>\n <div className=\"no-scrollbar overflow-y-auto px-4\">\n {Array.from({ length: 10 }).map((_, index) => (\n <p\n key={index}\n className=\"mb-4 leading-normal style-lyra:mb-2 style-lyra:leading-relaxed\"\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 </p>\n ))}\n </div>\n <DrawerFooter>\n <Button>Submit</Button>\n <DrawerClose render={<Button variant=\"outline\" />}>\n Cancel\n </DrawerClose>\n </DrawerFooter>\n </DrawerContent>\n </Drawer>\n ))}\n </div>\n </Example>\n )\n}\n\nfunction DrawerScrollableContent() {\n return (\n <Example title=\"Scrollable Content\">\n <Drawer swipeDirection=\"right\">\n <DrawerTrigger render={<Button variant=\"outline\" />}>\n Scrollable Content\n </DrawerTrigger>\n <DrawerContent>\n <DrawerHeader>\n <DrawerTitle>Move Goal</DrawerTitle>\n <DrawerDescription>Set your daily activity goal.</DrawerDescription>\n </DrawerHeader>\n <div className=\"no-scrollbar overflow-y-auto px-4\">\n {Array.from({ length: 10 }).map((_, index) => (\n <p\n key={index}\n className=\"mb-4 leading-normal style-lyra:mb-2 style-lyra:leading-relaxed\"\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 </p>\n ))}\n </div>\n <DrawerFooter>\n <Button>Submit</Button>\n <DrawerClose render={<Button variant=\"outline\" />}>\n Cancel\n </DrawerClose>\n </DrawerFooter>\n </DrawerContent>\n </Drawer>\n </Example>\n )\n}\n",
"type": "registry:example"
}
],
Expand Down
Loading