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

onoffcanvas

v3.0.0

Published

An offcanvas plugin

Readme

OnoffCanvas

Technical Prestige MIT License NPM Version NPM Downloads

OnoffCanvas is a lightweight, accessible, and high-performance JavaScript offcanvas plugin designed with a "Technical Prestige" aesthetic. It utilizes modern CSS clip-path animations and glassmorphism to provide a premium user experience.

[!WARNING] This plugin utilizes modern CSS features and does not support Internet Explorer.


✨ Features

  • 🚀 Performance: Powered by CSS clip-path for smooth, hardware-accelerated transitions.
  • 🛡️ Accessibility: Built-in ARIA support, keyboard navigation (Esc to close), and focus management.
  • 💎 Premium Design: Glassmorphic drawers with backdrop blur and a titanium-inspired palette.
  • 📍 Multiple Positions: Easily place panels at the top, bottom, start (left), end (right), or even center.
  • 🖱️ Hover Support: Optional hover-to-reveal functionality for effortless interaction.
  • 📦 Zero Dependencies: Lightweight footprint with no external library requirements.

📦 Installation

Install via your preferred package manager:

npm install onoffcanvas
# or
yarn add onoffcanvas

Deno

OnoffCanvas is fully compatible with Deno. You can import it directly from JSR or via an ESM CDN:

// From JSR
import OnoffCanvas from "jsr:@onokumus/onoffcanvas";

// Or from esm.sh
import OnoffCanvas from "https://esm.sh/onoffcanvas";

[!NOTE] When using in Deno for frontend development, you will still need to include the CSS file in your HTML or via your bundler.


Browser (CDN)

  1. Include the StyleSheet:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/onoffcanvas/lib/onoffcanvas.css">
  1. Include the plugin:
<script src="https://cdn.jsdelivr.net/npm/onoffcanvas/lib/onoffcanvas.js"></script>

🚀 Quick Start

1. HTML Markup

Define your offcanvas panel and a trigger element.

<div id="myCanvas" class="onoffcanvas is-start">
  <div class="p-8">
    <h1 class="tracking-widest font-light uppercase">Menu</h1>
    <p>Premium content goes here.</p>
  </div>
</div>

2. Trigger Options

You can trigger the offcanvas using a link or a button. Ensure you add data-toggle="onoffcanvas".

  • Using a Link:
<a href="#myCanvas" data-toggle="onoffcanvas">Toggle Menu</a>
  • Using a Button:
<button data-target="#myCanvas" data-toggle="onoffcanvas">Toggle Menu</button>

3. Initialization

import OnoffCanvas from 'onoffcanvas';
import 'onoffcanvas/style';

// Initialize all elements with data-toggle="onoffcanvas"
OnoffCanvas.autoinit();

// Or manual instance
const oc = new OnoffCanvas('#myCanvas', options);

🛠️ API Reference

Methods

  • OnoffCanvas.autoinit(options?): Auto-initializes all data-toggle="onoffcanvas" elements.
  • OnoffCanvas.attachTo(element, options?): Returns a new instance.
  • show(): Displays the panel.
  • hide(): Hides the panel.
  • toggle(): Toggles the state.
  • destroy(): Cleans up listeners and removes instance.
  • on(event, handler): Event listener helper.

Events

| Event Type | Description | | :--- | :--- | | show.onoffcanvas | Fires immediately when show is called. | | hide.onoffcanvas | Fires immediately when hide is called. |

const oc = new OnoffCanvas('#myCanvas');

oc.on('show.onoffcanvas', (event) => {
  console.log('Panel is showing', event.detail.instance);
});

oc.on('hide.onoffcanvas', (event) => {
  console.log('Panel is hiding', event.detail.element);
});

Options

| Option | Type | Default | Description | | :--- | :--- | :--- | :--- | | createDrawer | boolean | true | Whether to create a glassmorphic backdrop. | | hideByEsc | boolean | true | Close the panel when the Escape key is pressed. |


🎨 Customization

OnoffCanvas is built with CSS Variables for effortless theming:

:root {
  --oc-bg: #050505;
  --oc-color: #f5f5f7;
  --oc-width: 16rem;
  --oc-transition-duration: 0.5s;
  --oc-backdrop-blur: 12px;
  --oc-border-radius: 12px;
}

Canvas Options

1. Position Options

By default, the offcanvas is absolutely positioned. Add is-fixed for fixed positioning.

<div class="onoffcanvas is-fixed"></div>

2. Direction Options

Control the reveal direction using these classes:

  • is-top: Reveal from top.
  • is-bottom: Reveal from bottom.
  • is-start: Reveal from left (LTR).
  • is-end: Reveal from right (LTR).
  • is-center: Center expansion.
<div class="onoffcanvas is-start" id="side-canvas"></div>

3. Opened/Closed State

Add is-open to have the panel visible by default.

<div class="onoffcanvas is-open" id="side-canvas"></div>

4. Hoverable Support

To reveal the offcanvas on hover:

  1. Wrap it in a .onoffcanvas-container.
  2. Add .is-hoverable to the offcanvas element.
<div class="onoffcanvas-container">
  <div class="onoffcanvas is-hoverable" id="side-canvas"></div>
</div>

👤 Author

onokumus


📜 License

Distributed under the MIT License.