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

@wordpress/global-styles-engine

v1.18.0

Published

Pure CSS generation engine for WordPress global styles.

Readme

Global Styles Engine

A generic library for reading and writing global styles data structures (theme.json format).

Overview

This is a framework-agnostic utility library that provides functions for manipulating global styles objects. It handles the complex nested structure of theme.json format, including block-specific styles and settings.

API

Reading Data

getStyle(globalStyles, path, blockName?, shouldDecodeEncode?)

Get a style value from the global styles object.

// Get global text color
const textColor = getStyle( globalStyles, 'color.text' );

// Get button background color
const buttonBg = getStyle( globalStyles, 'color.background', 'core/button' );

// Get raw value without CSS variable resolution
const rawValue = getStyle( globalStyles, 'color.text', undefined, false );

getSetting(globalStyles, path, blockName?)

Get a setting value with fallback hierarchy (block-specific → global).

// Get global color palette
const colors = getSetting( globalStyles, 'color.palette' );

// Get paragraph-specific font sizes
const fontSizes = getSetting(
	globalStyles,
	'typography.fontSizes',
	'core/paragraph'
);

Writing Data

setStyle(globalStyles, path, newValue, blockName?)

Immutably set a style value. Returns a new global styles object.

// Set global text color
const updated = setStyle( globalStyles, 'color.text', '#333333' );

// Set button background color
const updated = setStyle(
	globalStyles,
	'color.background',
	'#0073aa',
	'core/button'
);

setSetting(globalStyles, path, newValue, blockName?)

Immutably set a setting value. Returns a new global styles object.

// Set global color palette
const updated = setSetting( globalStyles, 'color.palette', newPalette );

// Set block-specific settings
const updated = setSetting(
	globalStyles,
	'typography.fontSizes',
	sizes,
	'core/heading'
);

Utility Functions

getPalettes(globalStyles)

Extract color palettes organized by origin (theme, custom, default).

generateGlobalStyles(globalStyles)

Generate CSS from global styles object.

mergeGlobalStyles(base, user)

Merge multiple global styles objects with proper precedence.

Data Structure

The global styles object follows the theme.json schema:

{
  styles: {
    color: { text: '#000', background: '#fff' },
    typography: { fontSize: '16px' },
    elements: {
      button: { color: { background: 'blue' } }
    },
    blocks: {
      'core/paragraph': { color: { text: '#333' } }
    }
  },
  settings: {
    color: { palette: [...] },
    typography: { fontSizes: [...] },
    blocks: {
      'core/paragraph': { color: { text: true } }
    }
  }
}

Features

  • Immutable Updates: All setter functions return new objects
  • Type Safety: Full TypeScript support
  • CSS Variable Resolution: Automatic resolution of CSS custom properties
  • Block-Specific Styles: Support for block and element-specific styling
  • Fallback Hierarchy: Smart fallback from block → global → default settings
  • Framework Agnostic: No dependencies on React, WordPress, or other frameworks

Usage

This library is designed to be used as the foundation for any global styles editing interface. It provides the core data manipulation functions while remaining completely generic and reusable.

It is a prerequisite for use that blocks and their styles be globally registered, because block styles are fetched from the global blocks store.