npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

drawer-vue3

v0.2.0

Published

[中文](./README.zh-CN.md) | English

Readme

drawer-vue3

中文 | English

A flexible and powerful Drawer component wrapper for Vue 3 and Ant Design Vue. It simplifies drawer management by allowing you to open drawers programmatically, pass components and props dynamically, and handle footers with ease.

Features

  • Programmatic Control: Open and close drawers using inject or helper components.
  • Dynamic Content: Render any Vue component inside the drawer with props and context.
  • Footer Management: Easily render custom footers from within the drawer content using <DrawerFooter>.
  • Context Injection: Pass context data seamlessly to the drawer component.
  • Docked Mode: Support for docking the drawer within a specific container.

Installation

npm install drawer-vue3
# or
yarn add drawer-vue3

Ensure you have ant-design-vue and vue installed.

Usage

1. Setup

Wrap your application (or the part where you want drawers to appear) with DrawerProvider.

<template>
  <DrawerProvider>
    <App />
  </DrawerProvider>
</template>

<script setup>
import DrawerProvider from './src/DrawerProvider.vue'; // Adjust path based on your structure
</script>

2. Opening a Drawer

You can open a drawer using the provided openDrawer function or the DrawerOpener component.

Method A: Using inject

<script setup>
import { inject } from 'vue';
import MyComponent from './MyComponent.vue';

const openDrawer = inject('openDrawer');

const handleOpen = () => {
  openDrawer({
    component: MyComponent,
    props: { title: 'My Drawer', width: 500 }, // Ant Design Drawer props
    componentProps: { id: 123 }, // Props passed to MyComponent
    footer: true, // Enable footer area
  });
};
</script>

<template>
  <button @click="handleOpen">Open Drawer</button>
</template>

Method B: Using DrawerOpener

<template>
  <DrawerOpener
    :component="MyComponent"
    :props="{ title: 'My Drawer' }"
    :component-props="{ id: 123 }"
    footer
  >
    <template #default="{ open }">
      <button @click="open">Open Drawer</button>
    </template>
  </DrawerOpener>
</template>

<script setup>
import DrawerOpener from './src/DrawerOpener.vue';
import MyComponent from './MyComponent.vue';
</script>

3. Custom Footer

Inside your drawer component (MyComponent.vue), you can render content into the drawer's footer using DrawerFooter.

<template>
  <div>
    <h1>Drawer Content</h1>
    <p>Some content here...</p>

    <DrawerFooter>
      <a-button @click="close">Cancel</a-button>
      <a-button type="primary" @click="save">Save</a-button>
    </DrawerFooter>
  </div>
</template>

<script setup>
import { inject } from 'vue';
import DrawerFooter from './src/DrawerFooter.vue';

const closeDrawer = inject('closeDrawer');

const close = () => {
  closeDrawer();
};

const save = () => {
  // Logic...
  closeDrawer();
};
</script>

API

DrawerProvider

| Prop | Type | Default | Description | | --- | --- | --- | --- | | drawer | Object | {} | Default props applied to the underlying a-drawer. | | docked | Boolean | false | If true, the drawer container positions absolutely within its parent. |

openDrawer Options

| Property | Type | Description | | --- | --- | --- | | component | Component | The Vue component to render inside the drawer. | | props | Object | Props passed to a-drawer (e.g., title, width, maskClosable). | | componentProps | Object | Props passed to the rendered component. | | componentContext | Object | Additional context provided to the component (accessible via inject). | | footer | Boolean | Whether to enable the footer portal. Default false. |

DrawerOpener Props

| Prop | Type | Required | Description | | --- | --- | --- | --- | | component | Component | Yes | The component to render. | | props | Object | No | Props for the drawer. | | componentProps | Object | Yes | Props for the component. | | componentContext | Object | No | Context for the component. | | footer | Boolean | No | Enable footer. Default false. | | closeOnDestroy | Boolean | No | Close drawer when opener unmounts. Default true. |