{ "name": "drawer", "file": "compositions/ui/drawer", "snippet": "import { Drawer as ChakraDrawer, Portal } from \"@chakra-ui/react\"\nimport { CloseButton } from \"@/components/ui/close-button\"\nimport * as React from \"react\"\n\ninterface DrawerContentProps extends ChakraDrawer.ContentProps {\n portalled?: boolean\n portalRef?: React.RefObject\n offset?: ChakraDrawer.ContentProps[\"padding\"]\n}\n\nexport const DrawerContent = React.forwardRef<\n HTMLDivElement,\n DrawerContentProps\n>(function DrawerContent(props, ref) {\n const { children, portalled = true, portalRef, offset, ...rest } = props\n return (\n \n \n \n {children}\n \n \n \n )\n})\n\nexport const DrawerCloseTrigger = React.forwardRef<\n HTMLButtonElement,\n ChakraDrawer.CloseTriggerProps\n>(function DrawerCloseTrigger(props, ref) {\n return (\n \n \n \n )\n})\n\nexport const DrawerTrigger = ChakraDrawer.Trigger\nexport const DrawerRoot = ChakraDrawer.Root\nexport const DrawerFooter = ChakraDrawer.Footer\nexport const DrawerHeader = ChakraDrawer.Header\nexport const DrawerBody = ChakraDrawer.Body\nexport const DrawerBackdrop = ChakraDrawer.Backdrop\nexport const DrawerDescription = ChakraDrawer.Description\nexport const DrawerTitle = ChakraDrawer.Title\nexport const DrawerActionTrigger = ChakraDrawer.ActionTrigger\n", "examples": [ { "name": "drawer-basic", "content": "export const DrawerBasic = () => {\n return (\n \n \n \n \n \n \n \n \n \n Drawer Title\n \n \n

\n Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do\n eiusmod tempor incididunt ut labore et dolore magna aliqua.\n

\n
\n \n \n \n \n \n \n \n
\n
\n
\n
\n )\n}\n", "hasSnippet": false, "importPaths": [ "import { Button, CloseButton, Drawer, Portal } from \"@chakra-ui/react\"" ], "importPath": "import { Drawer } from \"@chakra-ui/react\"" }, { "name": "drawer-controlled", "content": "\"use client\"\nexport const DrawerControlled = () => {\n const [open, setOpen] = useState(false)\n\n return (\n setOpen(e.open)}>\n \n \n \n \n \n \n \n \n Drawer Title\n \n \n

\n Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do\n eiusmod tempor incididunt ut labore et dolore magna aliqua.\n

\n
\n \n \n \n \n \n \n \n
\n
\n
\n
\n )\n}\n", "hasSnippet": false, "importPaths": [ "import { Button, CloseButton, Drawer, Portal } from \"@chakra-ui/react\"", "import { useState } from \"react\"" ], "importPath": "import { Drawer } from \"@chakra-ui/react\"" }, { "name": "drawer-with-conditional-variants", "content": "export const DrawerWithConditionalVariants = () => {\n return (\n <>\n Open drawer and resize screen to mobile size\n \n \n \n \n \n \n \n \n \n Drawer Title\n \n \n Press the esc key to close the drawer.\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n )\n}\n", "hasSnippet": false, "importPaths": [ "import {\n Button,\n CloseButton,\n Drawer,\n Kbd,\n Portal,\n Text,\n} from \"@chakra-ui/react\"" ], "importPath": "import { Drawer } from \"@chakra-ui/react\"" }, { "name": "drawer-with-context", "content": "\"use client\"\nexport const DrawerWithContext = () => {\n return (\n \n \n \n \n \n \n \n \n \n {(store) => (\n \n

Drawer is open: {store.open ? \"true\" : \"false\"}

\n

\n Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed\n do eiusmod tempor incididunt ut labore et dolore magna\n aliqua.\n

\n \n
\n )}\n
\n \n \n \n
\n
\n
\n
\n )\n}\n", "hasSnippet": false, "importPaths": [ "import { Button, CloseButton, Drawer, Portal } from \"@chakra-ui/react\"" ], "importPath": "import { Drawer } from \"@chakra-ui/react\"" }, { "name": "drawer-with-custom-container", "content": "\"use client\"\nconst DrawerContainer = forwardRef(\n function DrawerContainer(props, ref) {\n return (\n \n )\n },\n)\n\nexport const DrawerWithCustomContainer = () => {\n const portalRef = useRef(null)\n return (\n \n \n Render drawer here\n \n \n \n \n \n \n \n \n \n Drawer Title\n \n \n \n \n \n

\n Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do\n eiusmod tempor incididunt ut labore et dolore magna aliqua.\n

\n
\n \n \n \n \n
\n
\n
\n
\n )\n}\n", "hasSnippet": false, "importPaths": [ "import {\n Button,\n CloseButton,\n Drawer,\n Portal,\n Stack,\n type StackProps,\n Text,\n} from \"@chakra-ui/react\"", "import { forwardRef, useRef } from \"react\"" ], "importPath": "import { Drawer } from \"@chakra-ui/react\"" }, { "name": "drawer-with-header-actions", "content": "export const DrawerWithHeaderActions = () => {\n return (\n \n \n \n \n \n \n \n \n \n \n \n \n Drawer Title\n \n \n \n \n \n \n

\n Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do\n eiusmod tempor incididunt ut labore et dolore magna aliqua.\n

\n
\n
\n
\n
\n
\n )\n}\n", "hasSnippet": false, "importPaths": [ "import {\n Button,\n ButtonGroup,\n CloseButton,\n Drawer,\n Portal,\n} from \"@chakra-ui/react\"" ], "importPath": "import { Drawer } from \"@chakra-ui/react\"" }, { "name": "drawer-with-initial-focus", "content": "\"use client\"\nexport const DrawerWithInitialFocus = () => {\n const ref = useRef(null)\n return (\n ref.current}>\n \n \n \n \n \n \n \n \n Drawer Title\n \n \n

\n Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do\n eiusmod tempor incididunt ut labore et dolore magna aliqua.\n

\n \n \n \n \n
\n \n \n \n \n \n \n \n
\n
\n
\n
\n )\n}\n", "hasSnippet": false, "importPaths": [ "import {\n Button,\n CloseButton,\n Drawer,\n Input,\n Portal,\n Stack,\n} from \"@chakra-ui/react\"", "import { useRef } from \"react\"" ], "importPath": "import { Drawer } from \"@chakra-ui/react\"" }, { "name": "drawer-with-offset", "content": "export const DrawerWithOffset = () => {\n return (\n \n \n \n \n \n \n \n \n \n Drawer Title\n \n \n

\n Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do\n eiusmod tempor incididunt ut labore et dolore magna aliqua.\n

\n
\n \n \n \n \n \n \n \n
\n
\n
\n
\n )\n}\n", "hasSnippet": false, "importPaths": [ "import { Button, CloseButton, Drawer, Portal } from \"@chakra-ui/react\"" ], "importPath": "import { Drawer } from \"@chakra-ui/react\"" }, { "name": "drawer-with-placement", "content": "export const DrawerWithPlacement = () => {\n return (\n \n \n {(placement) => (\n \n \n \n \n \n \n \n \n \n Drawer Title\n \n \n Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed\n do eiusmod tempor incididunt ut labore et dolore magna\n aliqua.\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n )}\n \n \n )\n}\n", "hasSnippet": false, "importPaths": [ "import {\n Button,\n CloseButton,\n Drawer,\n For,\n HStack,\n Portal,\n} from \"@chakra-ui/react\"" ], "importPath": "import { Drawer } from \"@chakra-ui/react\"" }, { "name": "drawer-with-sizes", "content": "export const DrawerWithSizes = () => {\n return (\n \n \n {(size) => (\n \n \n \n \n \n \n \n \n \n Drawer Title\n \n \n Press the esc key to close the drawer.\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n )}\n \n \n )\n}\n", "hasSnippet": false, "importPaths": [ "import {\n Button,\n CloseButton,\n Drawer,\n For,\n HStack,\n Kbd,\n Portal,\n} from \"@chakra-ui/react\"" ], "importPath": "import { Drawer } from \"@chakra-ui/react\"" } ] }