Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@wordpress/theme

Package Overview
Dependencies
Maintainers
23
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wordpress/theme

Theme and context provider for the WordPress Design System.

Source
npmnpm
Version
0.3.0
Version published
Weekly downloads
122K
-3.28%
Maintainers
23
Weekly downloads
 
Created
Source

Theme

This package is still experimental. “Experimental” means this is an early implementation subject to drastic and breaking changes.

A theming package that's part of the WordPress Design System. It has two parts:

  • Design Tokens: A comprehensive system of design tokens for colors, spacing, typography, and more
  • Theme System: A flexible theming provider for consistent theming across applications

Design Tokens

In the Design Tokens Reference document there is a complete reference of all available design tokens including colors, spacing, typography, and more.

Color Tokens

The design system defines color tokens using the following naming scheme:

--wpds-<element>-<tone>[-<emphasis>][-<state>]

Element specifies what the color is applied to.

ValueDescription
bg-surfaceBackgrounds of layout or container surfaces.
bg-interactiveBackgrounds of interactive elements such as buttons, inputs, and toggles.
bg-trackBackgrounds of track components like scrollbars and slider tracks.
bg-thumbBackgrounds of thumb components like scrollbar thumbs and slider thumbs.
fg-contentForeground color for text and icons in static content.
fg-interactiveForeground color for text and icons in interactive elements such as links and buttons.
stroke-surfaceDecorative borders and dividers for non-interactive surfaces.
stroke-interactiveAccessible borders for interactive controls.
stroke-focusStroke color specifically for focus rings.

Tone defines the semantic intent of the color.

ValueDescription
neutralNeutrally toned UI elements.
brandBrand-accented or primary action colors.
successPositive or completed states.
infoInformational or system-generated context.
cautionHeads-up or low-severity issues; “proceed carefully.”
warningHigher-severity or time-sensitive issues that require user attention but are not errors.
errorBlocking issues, validation failures, or destructive actions.

[!NOTE] caution and warning represent two escalation levels of non-error severity. Use caution for guidance or minor risks, and warning when the user must act to prevent an error.

Emphasis adjusts color strength relative to the base tone, if specified. The default is a normal emphasis.

ValueDescription
strongHigher contrast and/or elevated emphasis.
weakSubtle variant for secondary or muted elements.

State represents the interactive state of the element, if specified. The default is an idle state.

ValueDescription
activeHovered, pressed, or selected state.
disabledUnavailable or inoperable state.

Theme Provider

The ThemeProvider is a React component that should wrap your application to provide design tokens and theme context to the child UI components. It accepts a set of customizable seed values and automatically generates a set of design tokens, which are exposed as CSS custom properties for use throughout the application.

import { ThemeProvider } from '@wordpress/theme';

function App() {
	return (
		<ThemeProvider color={ { primary: 'blue' } }>
			{ /* Your app content */ }
		</ThemeProvider>
	);
}

The color prop accepts an object with the following optional properties:

  • primary: The primary/accent seed color (default: '#3858e9')
  • bg: The background seed color (default: '#f8f8f8')

Both properties accept any valid CSS color value. The theme system automatically generates appropriate color ramps and determines light/dark mode based on these seed colors.

Nesting Providers

The provider can be used recursively to override or modify the theme for a specific subtree.

<ThemeProvider color={ { bg: 'white' } }>
	{ /* light-themed UI components */ }
	<ThemeProvider color={ { bg: '#1e1e1e' } }>
		{ /* dark-themed UI components */ }
		<ThemeProvider color={ { primary: 'red' } }>
			{ /* dark-themed with red accent */ }
		</ThemeProvider>
	</ThemeProvider>
	{ /* light-themed UI components */ }
</ThemeProvider>

The ThemeProvider redefines some of the design system tokens. Components consuming semantic design system tokens will automatically follow the chosen theme. Note that the tokens are defined and inherited using the CSS cascade, and therefore the DOM tree, not the React tree. This is very important when using React portals.

Building

This package is built in two steps. When npm run build is run at the root of the repo, it will first run the "prebuild" step of this package, which is defined in the build script of this package's package.json.

This step will:

  • Generate primitive tokens.
  • Build CSS and JavaScript token files.
  • Update the design tokens documentation.
  • Format all generated files.

The files generated in this step will all be committed to the repo.

After the prebuild step, the package will be built into its final form via the repo's standard package build script.

Contributing to this package

This is an individual package that's part of the Gutenberg project. The project is organized as a monorepo. It's made up of multiple self-contained software packages, each with a specific purpose. The packages in this monorepo are published to npm and used by WordPress as well as other software projects.

To find out more about contributing to this package or Gutenberg as a whole, please read the project's main contributor guide.



Code is Poetry.

Keywords

wordpress

FAQs

Package last updated on 26 Nov 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts