Skip to content

Improve CSS setup instructions in package readmes#76975

Merged
mirka merged 5 commits intotrunkfrom
readme-css-setup
Apr 3, 2026
Merged

Improve CSS setup instructions in package readmes#76975
mirka merged 5 commits intotrunkfrom
readme-css-setup

Conversation

@mirka
Copy link
Copy Markdown
Member

@mirka mirka commented Apr 1, 2026

What?

Adds a Set up section to the readmes for @wordpress/admin-ui, @wordpress/components, @wordpress/dataviews, and @wordpress/ui, covering stylesheet dependencies for WordPress plugins and for apps outside WordPress.

Why?

These packages depend on CSS from themselves and/or other packages. Instructions were split across sections or easy to miss, and non‑WordPress setups did not always spell out install steps, import order, RTL paths, or which wp_enqueue_style handles to depend on.

How?

  • Within WordPress: Document registering the right stylesheet handles as dependencies of the consumer’s stylesheet (with a link to wp_enqueue_style).
  • Outside WordPress: Document npm install where needed and import examples for @wordpress/theme/design-tokens.css and @wordpress/components/build-style/style.css, plus RTL paths for components CSS where applicable.
  • @wordpress/ui: Clarify that WordPress loads styles for you; outside WordPress, recommend design tokens for full theming and add a short note about isolation: isolate on the layout root for portaled popovers.

Testing Instructions

See that the instructions are correct and make sense.

Use of AI Tools

Composer 2 was used to draft this PR description.

@mirka mirka self-assigned this Apr 1, 2026
@mirka mirka added the [Type] Developer Documentation Documentation for developers label Apr 1, 2026
@github-actions github-actions bot added [Package] Components /packages/components [Package] DataViews /packages/dataviews [Package] UI /packages/ui labels Apr 1, 2026

### Within WordPress

To ensure proper load order, add the `wp-components` stylesheet as a dependency of your plugin's stylesheet. See [wp_enqueue_style documentation](https://developer.wordpress.org/reference/functions/wp_enqueue_style/#parameters) for how to specify dependencies.
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.

@wordpress/dataviews and @wordpress/admin-ui don't have a stylesheet handle, so there's currently no reliable way for a third-party WP plugin to load the package styles without potentially loading duplicate or conflicting styles on a given route. (If something else is loading the same package styles on the same route.)

Maybe that's fine, but mentioning here for completeness (cc @oandregal).

@mirka mirka marked this pull request as ready for review April 1, 2026 21:52
@mirka mirka requested review from a team, ajitbohra, gigitux, ntsekouras and oandregal as code owners April 1, 2026 21:52
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 1, 2026

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: mirka <0mirka00@git.wordpress.org>
Co-authored-by: aduth <aduth@git.wordpress.org>

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

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 1, 2026

Flaky tests detected in b8eb232.
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/23949739516
📝 Reported issues:

Copy link
Copy Markdown
Member

@aduth aduth left a comment

Choose a reason for hiding this comment

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

Some minor comments, but LGTM overall 👍

npm install @wordpress/admin-ui --save
```

## Set up
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Super nit: But I kept wondering if this should be "setup" or "set up", but in turn it made me think it's not a very common heading I see in READMEs, compared to something like "Getting started", "Usage", maybe "Setup instructions", etc.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Although in the case of components package here, it already has "Usage". And we're treating this as something different 🤔 Maybe it's fine to have a separate section for this "necessary steps between installation and usage". Or we could fold it into an existing section. "Setup" is probably more consistent as a noun heading though, if we kept it.

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.

Good point about the noun/verb agreement. Turns out "Setup" is used as a heading in some other packages in here as well, so I went with that ecf4fd6.

Comment on lines +33 to +34
import '@wordpress/components/build-style/style.css';
import '@wordpress/admin-ui/build-style/style.css';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Aside: It would be really nice if we made a subpath export with a nicer import path here, to avoid build-style being part of the import path. Feels like an implementation detail we shouldn't need to expose to end-users 🤷

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.

On the other hand, it's probably a pretty niche use case to use these libraries outside of WordPress?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

True, not an especially urgent problem. More to the general consistency of how we want to use subpath exports. They're a public API. But build-style means nothing and could disappear or be renamed tomorrow if we wanted it to.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

it's probably a pretty niche use case to use these libraries outside of WordPress?

Note that until admin-ui is bundled by default by tooling provided by Gutenberg, the import is mandatory also in WP Admin contexts.

It might even help clarify in docs that component style is required to import only outside WP contexts, and the other two in all contexts?

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.

Note that until admin-ui is bundled by default by tooling provided by Gutenberg, the import is mandatory also in WP Admin contexts.

I've raised this as a structural problem for both DataViews and Admin UI. Possibly less of a problem for Admin UI, if there's less chance of stylesheet conflicts on a given route (as opposed to e.g. DataForm, which could more plausibly have multiple separate bundles loading into a single route). I believe the simplest solution for Admin UI would be to switch to our CSS module injection system (#77032).

import '@wordpress/admin-ui/build-style/style.css';
```

RTL versions of the stylesheets are available in the same paths, but with `-rtl` appended to the filename (`style-rtl.css`). The design tokens stylesheet is universal and does not have a separate RTL version.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wonder if it's worth clarifying that we don't ship an RTL-specific stylesheet for the ui package.

I also wonder what level of effort would be involved in removing it from this admin-ui package, since it doesn't include a whole lot and might be easy to migrate to logical properties.

Copy link
Copy Markdown
Member Author

@mirka mirka Apr 3, 2026

Choose a reason for hiding this comment

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

I wonder if it's worth clarifying that we don't ship an RTL-specific stylesheet for the ui package.

The "The design tokens stylesheet is universal and does not have a separate RTL version." line at the end was supposed to be this clarification. Was that unclear or did you mean something else?

I also wonder what level of effort would be involved in removing it from this admin-ui package, since it doesn't include a whole lot and might be easy to migrate to logical properties.

Oh yes, should be pretty easy especially at this early stage. Also a move to CSS modules. In light of the #76744 problem too, I'm thinking we can enforce the "CSS modules + logical properties" combination repo-wide on packages that want to adopt this new setup we already do 😄.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The "The design tokens stylesheet is universal and does not have a separate RTL version." line at the end was supposed to be this clarification. Was that unclear or did you mean something else?

I was more referring to a note in packages/ui/README.md for someone who might be confused about the absence of an RTL stylesheet. There's an implication here that downstream consumers will be handling RTL concerns, so if I'm an app developer and I know that I need to handle RTL, I might be confused if I can't find any mention of a stylesheet I need to load for RTL in @wordpress/ui documentation.

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.

Ah, I see. Added in b8eb232.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah, I see. Added in b8eb232.

Thanks, looks great 👍

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.

Issue for CSS module migration of admin-ui package: #77032

@mirka mirka enabled auto-merge (squash) April 3, 2026 14:33
@mirka mirka merged commit 49b4af3 into trunk Apr 3, 2026
43 of 49 checks passed
@mirka mirka deleted the readme-css-setup branch April 3, 2026 15:10
@github-actions github-actions bot added this to the Gutenberg 23.0 milestone Apr 3, 2026
@oandregal
Copy link
Copy Markdown
Member

Thanks for the changes, this reads a lot better.

adamsilverstein pushed a commit that referenced this pull request Apr 7, 2026
* Improve CSS setup instructions in readmes

* Fix

* Remove non-existent stylesheet handles

* Use Setup as readme section heading

* Add note to ui readme about no RTL version

Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: aduth <aduth@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Components /packages/components [Package] DataViews /packages/dataviews [Package] UI /packages/ui [Type] Developer Documentation Documentation for developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants