documentation/docs/ui-integrations/ant-design/hooks/use-drawer/index.md
The useDrawer hook helps you manage the Ant Design Drawer component.
const { show, close, drawerProps } = useDrawer();
You can use the show and close props to control the drawer visibility. You have to descturt drawerProps to the <Drawer/> component.
Let's see an example:
// highlight-start
import { useDrawer } from "@refinedev/antd";
import { Drawer, Button } from "antd";
// highlight-end
export const PostList: React.FC = () => {
// highlight-next-line
const { show, drawerProps } = useDrawer();
return (
<>
// highlight-start
<Button onClick={show}>Show Drawer</Button>
<Drawer {...drawerProps}>
<p>Drawer Content</p>
</Drawer>
// highlight-end
</>
);
};
Here, we show a button somewhere on the page and use show on it's onClick callback to trigger opening of the <Drawer>. When the user clicks on the button, the <Drawer> appears.
| Key | Description | Type |
|---|---|---|
| show | Returns the visibility state of the Drawer | () => void |
| close | A function that can open the drawer | () => void |
| drawerProps | Specify a function that can close the drawer | () => void |