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

@adyen/adyen-shared-web

v0.6.0

Published

Downloads

15,394

Readme

adyen-shared-web

Shared utilities for the Adyen npm libraries.

Usage

Install the package and create a ThemeGenerator to generate and inject semantic CSS color variables for your application:

import { ThemeGenerator } from "@adyen/adyen-shared-web";

const themeGenerator = new ThemeGenerator();

themeGenerator.create({
  primary: "#0066ff",
  background: "#ffffff",
  neutral: "#f2f4f7",
  label: "#101828",
  outline: "#98a2b3",
  highlight: "#006bd7",
  roundness: "medium",
});

Every input is optional. The generator only emits the tokens that the supplied inputs affect:

  • primary sets the brand color (background-inverse-primary, links, selection and emphasized outlines). Links get at least 4.5:1 contrast against the background. The text on the primary (label-inverse-primary) is light or dark, whichever is readable on the primary and its hover and active states. The hover and active states move away from that text, so they are at least as readable as the primary itself; a primary close to black or white keeps the Bento direction. The other inverse surfaces that carry this text, such as applied filter chips and avatars, are derived from the primary so the text stays readable on them: deep shades with light text, and shades close to the primary with dark text. In light mode, dark text on the primary also makes label-on-color dark, because Bento uses it for the active step number on the primary.
  • background sets the page background. Surfaces, status colors (critical, success, warning), highlight colors and, without outline, outlines and separators adapt to it. With the default background, they keep their Bento values.
  • neutral sets the secondary surfaces and separators. It also tints the inverse outlines and, without primary, the inverse surfaces. Both keep their Bento lightness.
  • label sets the primary text color. Secondary and tertiary labels are derived from it with a minimum contrast.
  • highlight sets the informative color (label-highlight). Without it, the Bento informative blue is used. Highlight and selected colors (background-selected*, the same color as background-highlight-weak in Bento) are never derived from primary.
  • outline sets the outline colors.
  • labelOnPrimary sets the text on the primary (label-inverse-primary) instead of the automatic light or dark text. It is used exactly, and the inverse surfaces and, in light mode with dark text, label-on-color follow it. It has an effect only together with primary.

Input colors are never changed. Derived text and outline colors (secondary labels, links, status and highlight colors) keep their minimum contrast on the primary, secondary and tertiary background surfaces, because text also sits on secondary surfaces such as cards, drawers and the selected Adyen Web payment method. In development builds, the generator warns when an input color has low contrast. It also warns when the text on the primary is not the Bento default and is used on other colors where it has low contrast: critical and success colors, and checked read-only toggles, whose icon uses the label color as background.

Set roundness to "small", "medium", or "large" to set border-radius-m to 4px, 8px, or 12px. The xs, s, l, and xl radius tokens keep the Bento proportions around it. Pass dark: true when generating a dark theme. Call themeGenerator.destroy() when the theme is no longer needed to remove the generated styles.

To generate CSS without accessing or modifying the DOM, use generateCSS(). It targets :root by default and accepts a custom selector for scoped themes:

const css = themeGenerator.generateCSS(
  {
    primary: "#0066ff",
    dark: true,
  },
  {
    selector: "[data-adyen-pe-theme-root='core-id']",
  },
);

generateCSS() returns null when no supplied theme input produces CSS variables.

Theme documents

A theme editor works with a ThemeDocument: the seeds of both modes and one roundness, in the form that is stored and shared.

import {
  applyTheme,
  createThemeDocument,
  parseTheme,
  resolveTheme,
  serializeTheme,
} from "@adyen/adyen-shared-web";

const theme = createThemeDocument(); // { v: 1, light: {}, dark: {} }
theme.light.primary = "#0066ff";
theme.dark.primary = "#84adff";
theme.roundness = "large";

const props = resolveTheme(theme, "dark"); // ThemeProps for one mode, with dark: true
const stored = serializeTheme(theme); // JSON string
const restored = parseTheme(stored); // never throws

const cleanup = applyTheme(previewElement, theme, "light");
  • THEME_SEEDS lists the color inputs in editor order, and DEFAULT_THEME_SEEDS holds the values an editor shows for unset seeds. Defaults are never written into a document: an unset seed keeps the Bento default.
  • resolveTheme() and serializeTheme() drop empty and invalid colors, so a half-typed value never makes generateCSS() throw.
  • parseTheme() accepts a JSON string or an object. It ignores unknown keys, invalid colors and invalid roundness, and returns an empty document for anything that is not a theme. A flat ThemeProps object is read as the seeds of its mode (dark: true means dark).
  • applyTheme() themes one container and everything inside it. Each container gets its own data-adyen-theme-root attribute and its own <style>, in the container's shadow root or the document head, so containers never overwrite each other. Calling it again for the same container updates that style. It also sets color-scheme on the container, accepts a prefix option like the ThemeGenerator constructor, and returns a cleanup that removes the style, the attribute and the color-scheme.
  • applyTheme() suits SDKs that read the --adyen-sdk-* variables from an ancestor, such as Adyen Web. Platform Experience and KYC take the theme through their own options, so pass them resolveTheme() output instead.

Publishing a new release on npm

  1. Tag the main branch with the new semantic version: git tag vX.Y.Z and git push origin vX.Y.Z
  2. Create a new release on GitHub (GitHub will automatically populate this with a changelog based on merged PRs).
  3. (Optional) If you want this to be a pre-release, check the "Set as pre-release" option.
  4. Publish the release!

Staged publishing is intentionally disabled at the moment.