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

@papit/icon

v0.1.10

Published

Renders SVG icons inline from a URL, a spritesheet symbol or a registered string, and country flags from a two-letter code. Fetched icons are shared between instances and can be cached in localStorage.

Readme

@papit/icon

Renders SVG icons inline from a URL, a spritesheet symbol or a registered string, and country flags from a two-letter code. Fetched icons are shared between instances and can be cached in localStorage.

Logo


Type Tests NPM version


Installation

npm install @papit/icon

Usage

Import

import "@papit/icon";

By name

A bare name is fetched from the site root: moon loads /moon.svg.

<pap-icon name="moon"></pap-icon>

By URL

<pap-icon name="https://example.com/icons/sun.svg"></pap-icon>
<pap-icon name="./icons/sun.svg"></pap-icon>

From a spritesheet

The part after # picks the symbol. Every <symbol> in the sheet is registered under its id, so later icons from the same sheet need no fetch.

<pap-icon name="/icons/sprite.svg#blend"></pap-icon>
<pap-icon name="blend"></pap-icon>

Registered up front

import { Icon } from "@papit/icon";

Icon.icons.set("check", `<svg viewBox="0 0 24 24"><path d="M9 16.2 4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z"/></svg>`);
<pap-icon name="check"></pap-icon>

Flag

<pap-icon flag="se"></pap-icon>

Cache in localStorage

<pap-icon cache name="moon"></pap-icon>

Attributes / Properties

| Attribute | Property | Type | Default | Description | | --------- | --------- | --------- | -------------- | --------------------------------------------------------------------------- | | name | name | string | — | Registered icon name, bare name (fetched as /<name>.svg), URL, or url#symbol | | flag | flag | string | — | Country code (e.g. se, gb) rendered as a flag emoji. Takes priority over name | | cache | cache | boolean | false | Store fetched SVG text in localStorage and read it back before fetching | | storage | storage | string | "papit-icon" | localStorage key prefix; the key is prefix + URL |

The response must have an SVG Content-Type; anything else is logged and ignored.

Static

| Member | Type | Description | | ------------- | --------------------- | ------------------------------------------------------------------------ | | Icon.icons | Map<string, string> | Registry of SVG markup by name, shared by every pap-icon. Fetched icons land here too |


Slots

| Slot | Description | | --------- | -------------------------------------------------- | | (default) | Fallback content, e.g. text or an emoji. It stays rendered next to the icon once one loads |


Styling

| Part | Description | | ---------- | ---------------------------------- | | svg | A fetched SVG (not set on markup registered through Icon.icons) | | flag | The flag emoji wrapper | | fallback | The default slot |

The host is 24px square (--space-6) and the SVG fills it with currentColor (--text). Size and colour it from outside:

pap-icon {
  width: 32px;
  height: 32px;
  color: var(--primary);
}

Accessibility

The icon sets no role. Hide decorative icons from assistive tech, and name meaningful ones:

<pap-icon name="moon" aria-hidden="true"></pap-icon>
<pap-icon name="warning" role="img" aria-label="Warning"></pap-icon>

License

Licensed under the @Papit License 1.0 Copyright (c) 2024 Henry Pap (@onkelhoy)

Key points

  • ✅ Free to use in commercial projects
  • ✅ Free to modify and distribute
  • ✅ Attribution required
  • ❌ Cannot resell the component itself as a standalone product

See the LICENSE file for full details.


Related Components