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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@substrate-system/arrows

v0.0.36

Published

[![tests](https://img.shields.io/github/actions/workflow/status/substrate-system/arrows/nodejs.yml?style=flat-square)](https://github.com/substrate-system/arrows/actions/workflows/nodejs.yml) [![types](https://img.shields.io/npm/types/@substrate-system/ar

Readme

arrows

tests types module install size GZip size semantic versioning Common Changelog license

Next and previous icons as accessible web components.

See a live demo

Install

npm i -S @substrate-system/arrows

Modules

This exposes ESM and common JS via package.json exports field.

ESM

import { SubstrateBack, SubstrateNext } from '@substrate-system/arrows'

Common JS

const arrows = require('@substrate-system/arrows')

pre-built

This package exposes minified JS and CSS files too. Copy them to a location that is accessible to your web server, then link to them in HTML.

copy

cp ./node_modules/@substrate-system/arrows/dist/index.min.js \
    ./public/substrate-arrows.min.js
cp ./node_modules/@substrate-system/arrows/dist/style.min.css \
    ./public/substrate-arrows.css

HTML

<head>
    <link rel="stylesheet" href="./substrate-arrows.css">
</head>
<body>
    <substrate-back></substrate-back>
    <substrate-next></substrate-next>
    <!-- ... -->
    <script type="module" src="./substrate-arrows.min.js"></script>
</body>

CSS

Import CSS

import '@substrate-system/arrows/css'

Or minified:

import '@substrate-system/arrows/css/min'

Use

server side

This is implemented as an HTML web component, which means it can be easily rendered to a string, then made interactive on the client side.

Import the /html path in node, and use the .html or .outerHTML function for HTML content:

import {
    AnchorBack,
    AnchorNext,
    SubstrateBack,
    SubstrateNext
} from '@substrate-system/arrows/html'

// Basic usage
const backLink = AnchorBack.html({ href: '/abc' })
const nextButton = SubstrateNext.html({ disabled: true })

// multiple attributes
const styledButton = SubstrateBack.html({
    disabled: false,
    class: 'primary-btn',
    'data-testid': 'back-button',
    id: 'main-back'
})

const externalLink = AnchorNext.html({
    href: 'https://example.com',
    target: '_blank',
    rel: 'noopener noreferrer',
    class: 'external-link'
})

Each component also provides:

  • .TAG property with the custom element tag name
  • .outerHTML() function to render the complete custom element with wrapper tags
// Get the tag name
console.log(SubstrateBack.TAG) // 'substrate-back'

// Render complete element with wrapper (basic)
const completeButton = SubstrateBack.outerHTML({ disabled: true })
// Returns: <substrate-back disabled>
//            <button disabled>...</button>
//          </substrate-back>

const completeLink = AnchorNext.outerHTML({ href: '/next' })
// Returns: <anchor-next href="/next">
//            <a href="/next">...</a>
//          </anchor-next>

// Attributes are applied to both the custom element wrapper AND inner element
const styledButton = SubstrateBack.outerHTML({
    class: 'styled-btn',
    disabled: true,
    'data-testid': 'back-button'
})
// Returns: <substrate-back class="styled-btn" disabled data-testid="back-button">
//            <button class="styled-btn" disabled data-testid="back-button">...</button>
//          </substrate-back>

client side

If the component has been rendered on the server, then you just need to add interactivity on the client side.

Import from the /client path to include a "light" version of the component, that will not render anything; it will just attach event listeners.

import { SubstrateBack, SubstrateNext } from '@substrate-system/arrows/client'

Full client side

For when you want to render on the client, and also "hydrate" client-side.

Import the root path to include a web component that will both render itself, and also attach event listeners. This cannot be used in node, because it depends on browser APIs.

import { SubstrateBack, SubstrateNext } from '@substrate-system/arrows'
import { AnchorBack, AnchorNext } from '@substrate-system/arrows/links'

CSS

This depends on the visually-hidden CSS class. Import @substrate-system/a11y for this:

import '@substrate-system/a11y/visually-hidden'

Disabled status is handled correctly in JS, but the :disabled attribute in CSS doesn't work on custom elements. So target the nested button element.

/* application code */
substrate-next, substrate-back {
    & button {
        cursor: pointer;

        &:disabled {
            opacity: 0.4;
            cursor: initial;
        }
    }
}

/* anchors */
anchor-next, anchor-back {
    &.disabled {
        & a {
            opacity: 0.4;
        }
    }
}

Buttons

import { SubstrateBack, SubstrateNext } from '@substrate-system/arrows'

SubstrateBack.define()
SubstrateNext.define()

document.body.innerHTML += `
    <substrate-back></substrate-back>
    <substrate-next></substrate-next>
`

Links

Render an a element, not a button.

Setting .disabled = true, or setting the disabled attribute, on an anchor button will remove the href attribute from the internal link tag, effectively disabling it.

import {
    AnchorBack,
    AnchorNext
} from '@substrate-system/arrows/links'

AnchorBack.define()
AnchorNext.define()

document.body.innerHTML += `
  <anchor-back class="test" href="/back"></anchor-back>
  <anchor-next class="test" href="/next"></anchor-next>
`