close
Skip to content

enhancement: improve how extenders can add global CSS to editor and frontend #48454

@tresorama

Description

@tresorama

What problem does this address?

While working on a block theme for the first time, i was stuck at loading a global CSS with utilities classes inside.
The Developer experience is a mess currently.
This should be improved because extenders (theme dev /plugin dev) are crucial for Wordpress.

There are various bad "things" currently in place that a dev must fight against to complete a simple task.

I have made a tutorial post to illustrate the process

https://jacopomarrone.netlify.app/blog/load-global-css-in-block-theme-in-wordpress

Main Painponts

Should be easies to inject a simple CSS. With Javascript ??

We should know that iframe receive CSS assets only if some CSS selector are present. This alone is big ALARM that maybe a refactor is necessary.

Inject CSS to the editor iframe should be done with a dedicated hook or similar process, and now is not present.

Core css specificity is high for an extendible system:

  • in editor we must fight with a scoped selector and !important
  • in frontend we must fight with !important

It difficult to say to wordpress when to inject our custom css relative to the theme.json one. This lead us to increase even more the specificity of CSS selectors.

It impossible to add a medium amount of CSS without a CSS preprocessor that support nesting.

Imagine a child theme that want to overrides ?!?!?

Related

#48437
#41821
#38673 (comment)
#33212


What is your proposed solution?

Start discussing about how to improve these, and if necessary :

  • exposing a new API
  • consider a refactor
  • consider a redesign

Metadata

Metadata

Assignees

No one assigned

    Labels

    CSS StylingRelated to editor and front end styles, CSS-specific issues.Developer ExperienceIdeas about improving block and theme developer experience

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions