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

@k4k3ru/design-system-button

v1.1.0

Published

Utility for button component

Readme

@k4k3ru/design-system-button

A lightweight, accessible Button component for HTML applications. It provides BEM-based CSS, semantic color variants, responsive theme fallbacks, and an optional TypeScript-powered ripple interaction.

Installation

npm install @k4k3ru/design-system-button

The shared design tokens are optional. When they are not installed, the Button component uses its own light and dark fallback values.

npm install @k4k3ru/tokens

Usage

Import the shared tokens first when using them, followed by the Button stylesheet.

@import "@k4k3ru/tokens/dist/style.css";
@import "@k4k3ru/design-system-button/style.css";

Create a button using the .button block and its elements.

<button class="button button--success button--round" type="button">
  <svg class="button__icon" viewBox="0 0 24 24" aria-hidden="true">
    <!-- icon path -->
  </svg>
  <span class="button__label">Save changes</span>
</button>

Initialize the optional ripple interaction once per document.

import { Button } from "@k4k3ru/design-system-button";

const button = new Button();
button.run();

// Remove the delegated event listener when it is no longer needed.
button.destroy();

The CSS can be used without initializing JavaScript. Only the pointer ripple interaction requires JavaScript.

Modifiers

Appearance

  • .button--outlined
  • .button--text
  • .button--round

Size

  • .button--small
  • Default medium size
  • .button--large

Semantic color

  • .button--error
  • .button--info
  • .button--success
  • .button--warning

Modifiers can be combined.

<button class="button button--large button--error button--outlined button--round" type="button">
  <span class="button__label">Delete account</span>
</button>

Button group

Use the standalone .button-group block to arrange multiple buttons.

<div class="button-group">
  <button class="button button--text" type="button">
    <span class="button__label">Cancel</span>
  </button>
  <button class="button button--success" type="button">
    <span class="button__label">Save</span>
  </button>
</div>

Disabled state

Use the native disabled attribute for <button> elements.

<button class="button" disabled type="button">
  <span class="button__label">Unavailable</span>
</button>

aria-disabled="true" is also styled and excluded from ripple interactions. ARIA does not prevent activation by itself, so applications must suppress activation when it is used on links or other non-button elements.

Themes

Without shared tokens, the component follows the operating-system color scheme. An explicit theme can be selected on the root HTML element.

<html data-theme="light">
<html data-theme="dark">

When @k4k3ru/tokens is loaded, its color variables take precedence over the built-in fallback palette.

Customization

Override the public Button custom properties after importing the stylesheet.

:root {
  --button-background: #f1f3f5;
  --button-color-success: #087f5b;
  --button-height-medium: 2.75rem;
  --button-radius-round: 999px;
}

Variables prefixed with --_button- are internal implementation details and are not part of the public customization API.

Accessibility

  • Prefer the native <button> element.
  • Set type="button" unless the button submits a form.
  • Provide visible label text or an accessible name for icon-only buttons.
  • Decorative SVG icons should use aria-hidden="true".
  • Reduced-motion preferences disable ripple animation.

Development

From the repository root:

npm run typecheck
npm run build:button

To view the example with a local HTTP server:

python3 -m http.server 8000

Open http://localhost:8000/web/components/button/example/.

License

MIT

Smaller size

Use button--smaller on the component root. Height, padding, text and icon; alias of button--small.

See shared sizing guidance and examples.

Both button--smaller and its existing alias button--small apply the small font size and line height to the button itself as well as .button__label. Direct text and wrapped labels therefore both use 13px text / 18px line height with the shared tokens. Default and large button sizing is unchanged.

Default horizontal padding is .75rem per side for small/smaller, 1.25rem for medium, and 1.5rem for large (an increase of .25rem per side for small/smaller and .5rem for medium/large from the original defaults). Vertical padding and heights are unchanged. Override the existing --button-padding-small, --button-padding-medium or --button-padding-large for custom spacing; Button no longer inherits the generic --control-padding-* defaults.