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

ngx-swipe-menu

v0.0.5

Published

A component to create "swipe left to 'action'" experiences.

Readme

NgxSwipeMenu

A component to create "swipe left to 'action'" experiences.

Installation & Configuration

npm i --save ngx-swipe-menu hammerjs

After installation, you need to configure the providers in your app.config.ts file:

import { BrowserModule, HammerModule } from "@angular/platform-browser";
import { provideSwipeMenu } from 'ngx-swipe-menu';
import 'hammerjs';

// ....
export const appConfig: ApplicationConfig = {
    providers: [
        // ....
        importProvidersFrom(BrowserModule),
        importProvidersFrom(HammerModule),
        provideSwipeMenu(),
        // ...
    ]
};

Usage

On your controller, import the component:

// ...
import { NgxSwipeMenuComponent } from 'ngx-swipe-menu';

// ...
@Component({
    imports: [
        // ...
        NgxSwipeMenuComponent,
    ],
    // ...
})
// ...

On your template, use the component "around" the content you want to be "moved" when the user swipes left:

Swipe Left with custom action buttons

<!-- ... -->
<ul>
  <!-- by default, swipeLeft is the only activated -->
  <ngx-swipe-menu>
    <li><!-- ... --></li>
    <!-- if you want to customize the action buttons: -->
    <ng-template #swipeLeftActions>
      <button>Edit</button>
      <button>Remove</button>
    </ng-template>
  </ngx-swipe-menu>
</ul>
<!-- ... -->

Swipe Left without buttons and a default action (with "Archive" label) when user swipes left

In this example, we won't have action buttons. It can be useful for default actions, like "swipe left to archive" in gmail. We also pass a data variable, with the data that will be sent to our listener function when the user swipes.

This can be usefull to identify the item in a list of "swappable" items.

<!-- ... -->
<ul>
  <ngx-swipe-menu [showSwipeLeftActions]="false" swipeLeftActionLabel="Archive" (swipeLeftDefaultAction)="onSwipeLeft($event)" [data]="itemData">
    <li><!-- ... --></li>
  </ngx-swipe-menu>
</ul>
<!-- ... -->

Disable swipe Left and enable swipe right, with custom buttons

<!-- ... -->
<ul>
  <ngx-swipe-menu [enableSwipeLeft]="false" [enableSwipeRight]="true">
    <li><!-- ... --></li>
    <ng-template #swipeRightActions>
      <button>Edit</button>
      <button>Remove</button>
    </ng-template>
  </ngx-swipe-menu>
</ul>
<!-- ... -->

Swipe left to "Archive" and Swipe right to "Delete", with FontAwesome icons instead of labels

<!-- ... -->
<ul>
  <ngx-swipe-menu [enableSwipeLeft]="true" [enableSwipeRight]="true" [data]="itemData"
    swipeLeftActionIcon="fa-solid fa-box-archive" swipeRithgActionIcon="fa-solid fa-trash"
    (swipeLeftDefaultAction)="archiveItem($event)"
    (swipeRightDefaultAction)="deleteItem($event)"
  >
    <li><!-- ... --></li>
  </ngx-swipe-menu>
</ul>
<!-- ... -->

Custom buttons from ts code

// ...
import { NgxSwipeMenuComponent, SwipeMenuActions } from 'ngx-swipe-menu';

// ...
@Component({
    imports: [
        // ...
        NgxSwipeMenuComponent,
    ],
    // ...
})
export class MyComponent {
  // ...
  swipeActionItems = [
    {
      name: 'edit',
      icon: 'fa-pencil',
      class: 'action-edit-button',
      onClick: (event: any, data: any) => {
          console.log("Edit action with data: ", data);
      }
    },
    {
      name: 'delete',
      label: "Delete",
      class: 'action-edit-button',
      data: 'This data overwrites the generic data provided to the component',
      onClick: (event: any, data: any) => {
          console.log("Delete action with data: ", data);
      }
    }
  ] as SwipeMenuActions[];

  items = ["Item 1", "Item 2"];
  // ...
}
<!-- ... -->
<ul>
  @for (itemData of items; track itemData) {
    <ngx-swipe-menu [data]="itemData" [swipeLeftActions]="swipeActionItems">
      <li>{{itemData}}</li>
    </ngx-swipe-menu>
  }
</ul>
<!-- ... -->

Component inputs and outputs/events

General

  • minSwipeDistance (default=50):

The minimum distance (in pixels) the user must move the content to enable showing the menu itens.

  • data:

The data provided here will be sent in the second argument of all the event listeners

  • menuOpened (event):

An event emitted when the swipe gesture is finished and the actions menu is opened. The first argument passed to the listener function is the data provided for this item

  • menuClosed (event):

An event emitted when the actions menu is closed. The first argument passed to the listener function is the data provided for this item

Swipe Left Options

  • enableSwipeLeft (default=true):

Defines if the swipeLeft gesture is enabled

  • showSwipeLeftActions (default=true):

Defines if the menu actions buttons must be showed. If no, when the user finishes the swipeLeft gesture we emit the defaultSwipeLeftAction event

  • swipeLeftActions SwipeMenuActions[]:

A list of SwipeMenuActions structure to configure the menu actions that must be showed when the user swipes left

  • swipeLeftActionLabel :

The label to be showed when action buttons are deactivated for swipe left

  • swipeLeftActionIcon :

The classes to be applied when when action buttons are deactivated for swipe left

  • swipeLeftDefaultAction (event):

An event emitted when the user clicks the default button of the swipeLeft gesture, when showSwipeLeftActions=true, or else when finished the swipeLeft gesture. The first argument passed to the listener function is the data provided for this item

Swipe Right Options

  • enableSwipeRight (default=false):

Defines if the swipeRight gesture is enabled

  • showSwipeRightActions (default=true):

Defines if the menu actions buttons must be showed. If no, when the user finishes the swipeRight gesture we emit the defaultSwipeRightAction event

  • swipeRightActions SwipeMenuActions[]:

A list of SwipeMenuActions structure to configure the menu actions that must be showed when the user swipes right

  • swipeRightActionLabel :

The label to be showed when action buttons are deactivated for swipe right

  • swipeRightActionIcon :

The classes to be applied when when action buttons are deactivated for swipe right

  • swipeRightDefaultAction (event):

An event emitted when the user clicks the default button of the swipeRight gesture, when showSwipeRightActions=true, or else when finished the swipeRight gesture. The first argument passed to the listener function is the data provided for this item