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

magic-cards

v1.0.4

Published

Custom web component allowing to turn potentially any webpage element into a 3D magic card

Readme

magic-cards

What is that?

This is a custom web component allowing to turn potentially any webpage element into a 3D magic card.

See example: https://baunov.github.io/magic-cards/

The package includes 2 custom web components that can be used in any web page independent of framework (also without any framework):

  1. <x-magic-card>
  2. <x-magic-card-particles>

Installation

  1. From CDN:
<script src="https://unpkg.com/magic-cards"></script>
  1. From npm (https://www.npmjs.com/package/magic-cards):
npm install magic-cards --save

Basic usage

  1. Wrap page elements you wish to turn into 3d card with <x-magic-card></x-magic-card>.
  2. Assign background to card by setting slot="background" on the wrapped element.
  3. Assign content to card by setting slot="content" on the wrapped element.
  4. Optionally add <x-magic-card-particles count="20"></x-magic-card-particles> within a card if you'd like to add particles.

Example:

<x-magic-card radius="4">
    <div slot="content">
        <x-magic-card-particles count="20"></x-magic-card-particles>
    </div>
    <div slot="background" style="overflow: hidden; width: 120px; height: 140px; display: flex; justify-content: center">
        <img height="140" src="https://static0.gamerantimages.com/wordpress/wp-content/uploads/2022/04/the-witcher-3-dlc-ballad-heroes-geralt-gwent-hand.jpg">
    </div>
</x-magic-card>

Configuration

Cards are configured globally. When magic-cards module is installed on the page, it sets the MagicCardsManager property on window. To configure cards behavior, call MagicCardsManager.configure(<configuration object>) after script is loaded.

Example:

MagicCardsManager.configure({
    activeCardScale: 1.8,
    maxRotateX: 20,
    maxRotateY: 20,
    perspective: 400,
    scaleEasing: 1,
    rotateEasing: 9,
})

Parameters:

x-magic-card

  1. radius - card border radius
  2. disabled - sets card to be non-interactive and greyed-out

x-magic-card

  1. count - particles count

Reacting on card activation and styling

When a card becomes active, it sets active attribute on itself. That way you can set styles for slotted elements using x-magic-card[active] css selector. The card shadow DOM wrapper element can also be styled (e.g. add a border to the card) using css x-magic-card::part(card-container) selector.

Example:

x-magic-card[active] .card-title {
    color: red;
}

x-magic-card::part(card-container) {
    border: 1px solid rgba(255,255,255,0.3);
    background: black;
}

Listening to activation changes in JS:

You can listen to a custom event active-change on each card or on the parent. event.detail is boolean stating whether the given card is active. This event bubbles.

document.querySelector('.cards-container').addEventListener('active-change', (event) => {
    console.log(event.target, event.detail);
    if (event.detail) {
        console.log('Card active', event.target);
    } else {
        console.log('Card inactive', event.target);
    }
});

P.S. Hope you'll like the effect