Skip to content

Theme: Promote ThemeProvider to stable API#78958

Merged
aduth merged 5 commits into
trunkfrom
update/theme-provider-stable
Jun 23, 2026
Merged

Theme: Promote ThemeProvider to stable API#78958
aduth merged 5 commits into
trunkfrom
update/theme-provider-stable

Conversation

@aduth

@aduth aduth commented Jun 4, 2026

Copy link
Copy Markdown
Member

What?

Closes #76840
Closes #75319

Updates @wordpress/theme to export ThemeProvider and useThemeProviderStyles as part of its stable API.

Why?

How?

  • Removes lock-ing of private APIs from @wordpress/theme
  • Updates consumers to replace unlock-ing private APIs with direct import of the stable members

Testing Instructions

Verify no regressions in surfaces where ThemeProvider is used, for example the Fonts screen or Storybook Theme pages.

In Storybook:

  1. npm run storybook:dev
  2. Go to http://localhost:50240/?path=/docs/design-system-theme-theme-provider--docs

In Fonts screen:

  1. npm run dev
  2. Go to http://localhost:8888/wp-admin/themes.php?page=font-library-wp-admin&p=%2Ffont-list
  3. Verify that "Update" button color follows the current user theme color

Use of AI Tools

No AI was used.

@aduth aduth requested a review from a team as a code owner June 4, 2026 19:33
@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: aduth <[email protected]>
Co-authored-by: ciampo <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions github-actions Bot added [Package] Theme /packages/theme [Package] UI /packages/ui labels Jun 4, 2026
@aduth aduth added the [Type] New API New API to be used by plugin developers or package users. label Jun 4, 2026
@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown

Size Change: -1.24 kB (-0.02%)

Total Size: 7.5 MB

📦 View Changed
Filename Size Change
build/modules/boot/index.min.js 52.9 kB -63 B (-0.12%)
build/modules/content-types/index.min.js 159 kB -182 B (-0.11%)
build/scripts/block-directory/index.min.js 43.5 kB -198 B (-0.45%)
build/scripts/block-editor/index.min.js 381 kB -183 B (-0.05%)
build/scripts/customize-widgets/index.min.js 14.6 kB +6 B (+0.04%)
build/scripts/edit-post/index.min.js 52.9 kB -47 B (-0.09%)
build/scripts/edit-site/index.min.js 299 kB -135 B (-0.05%)
build/scripts/editor/index.min.js 475 kB -202 B (-0.04%)
build/scripts/format-library/index.min.js 30.8 kB -1 B (0%)
build/scripts/media-utils/index.min.js 114 kB -55 B (-0.05%)
build/scripts/theme/index.min.js 22.1 kB -180 B (-0.81%)

compressed-size-action

@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown

Flaky tests detected in b43c2be.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/26975139006
📝 Reported issues:

ciampo

This comment was marked as outdated.

@ciampo ciampo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is unrelated from the the package README that mentions This package is still experimental. "Experimental" means this is an early implementation subject to drastic and breaking changes, right?

Comment thread packages/theme/CHANGELOG.md
Comment thread packages/theme/src/index.ts Outdated
export { privateApis } from './private-apis';
export type * from './prebuilt/ts/token-types';
export { type ThemeProvider } from './theme-provider';
export { ThemeProvider } from './theme-provider';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that it;s a public API, we should probably add JSDocs to the ThemeProvider component

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that it;s a public API, we should probably add JSDocs to the ThemeProvider component

Yeah, good call. And this will benefit the MCP server once we expose it there.

@aduth aduth Jun 8, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that it;s a public API, we should probably add JSDocs to the ThemeProvider component

Yeah, good call. And this will benefit the MCP server once we expose it there.

Added in b7cdc2f. Feedback welcome on wording. I originally started from how we describe it in README.md but refined it a bit. Maybe we want to revisit the README phrasing as well. "provide design tokens" isn't exactly accurate, because the provider doesn't generate a full set of tokens.

I also altered the ESLint configuration in 2158b04 to support this, and add a more complex explanation of why that exclusion applies.

@aduth

aduth commented Jun 8, 2026

Copy link
Copy Markdown
Member Author

I guess this is unrelated from the the package README that mentions This package is still experimental. "Experimental" means this is an early implementation subject to drastic and breaking changes, right?

I overlooked that and my instinct would be to remove it, as the intention here is stabilizing the API. What do you think?

@ciampo

ciampo commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

I overlooked that and my instinct would be to remove it, as the intention here is stabilizing the API. What do you think?

Given that we're potentially going to apply breaking changes to the DS tokens in the upcoming weeks, we could leave it around and remove it only when we stabilize the whole package (ie. version 1.0?), leaving this PR focused on making ThemeProvider a public API.

@aduth

aduth commented Jun 8, 2026

Copy link
Copy Markdown
Member Author

I overlooked that and my instinct would be to remove it, as the intention here is stabilizing the API. What do you think?

Given that we're potentially going to apply breaking changes to the DS tokens in the upcoming weeks, we could leave it around and remove it only when we stabilize the whole package (ie. version 1.0?), leaving this PR focused on making ThemeProvider a public API.

Yeah, that makes sense. It was also an oversight on my part that this doesn't do anything toward actually marking the package for 1.0 release, so we could make the promotion to 1.x and removal of the "experimental" banner a separate follow-on task closer to the 7.1 public release. Maybe tying it with a specific milestone like beta or RC ?

@aduth

aduth commented Jun 22, 2026

Copy link
Copy Markdown
Member Author

@ciampo Do you think we're good to move forward with this, or were you considering this blocked by other theme stabilization work?

@ciampo

ciampo commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

#79254 should be the last PR introducing breaking changes in the tokens, should we wait for it to be merged first?

@ciampo ciampo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#79254 is now merged, let's go!

LGTM 🚀

@aduth aduth force-pushed the update/theme-provider-stable branch from 7c79f96 to 9497e61 Compare June 23, 2026 16:24
@aduth aduth merged commit 3fb683e into trunk Jun 23, 2026
45 checks passed
@aduth aduth deleted the update/theme-provider-stable branch June 23, 2026 17:21
@github-actions github-actions Bot added this to the Gutenberg 23.5 milestone Jun 23, 2026
@ciampo

ciampo commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

@aduth do you think we still need to

export type * from './prebuilt/ts/token-types';

from the package?

@ciampo

ciampo commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Also, it looks like packages/private-apis/src/implementation.ts still mentions @wordpress/theme ?

@aduth

aduth commented Jun 23, 2026

Copy link
Copy Markdown
Member Author

@aduth do you think we still need to

export type * from './prebuilt/ts/token-types';

from the package?

Do you think we shouldn't? Personally I don't view that as related to the ThemeProvider component if the thinking is that we only needed those types because the component was private. Whether we want it in the public API in general though, I'm open to revisiting. They could certainly provide some value, though their original introduction was largely around the Box component and tying its typings to what's available through prebuilt token types, and we've since moved away from that.

Also, it looks like packages/private-apis/src/implementation.ts still mentions @wordpress/theme ?

Good catch, I'll update that 👍

@ciampo

ciampo commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

They could certainly provide some value, though their original introduction was largely around the Box component and tying its typings to what's available through prebuilt token types, and we've since moved away from that.

I agree that they can provide value, but (especially given the nature of the package) I think we should only export what we know is needed as of now, and add more exports if necessary. The opposite won't be possible once the package is marked as stable

@aduth

aduth commented Jun 24, 2026

Copy link
Copy Markdown
Member Author

The opposite won't be possible once the package is marked as stable

We could still make backwards-incompatible changes to TypeScript typings, no? Since they're not part of the window.wp.theme global.

@ciampo

ciampo commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

The opposite won't be possible once the package is marked as stable

We could still make backwards-incompatible changes to TypeScript typings, no? Since they're not part of the window.wp.theme global.

Not sure, we received complaints in the past about breaking type changes, too — especially form the point of view of third party maintainers that need to support multiple versions of WP and therefore woulnd't be able to have a single implementation that satisfies all versions at the same time (cc @mirka)

@aduth

aduth commented Jun 24, 2026

Copy link
Copy Markdown
Member Author

That might be improved separately with #79455.

In any case, let's take a look. I know we use a couple of the types ourselves at the moment, but most of them are likely unused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Edit Site /packages/edit-site [Package] Theme /packages/theme [Package] UI /packages/ui [Type] New API New API to be used by plugin developers or package users.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Theme: Promote ThemeProvider from private to public API UI: Remove usage of private APIs

2 participants