Skip to content

[Feature Proposal] A way for plugins to mutate the theme #660

@benface

Description

@benface

By "mutate the theme" I mean add utilities on top of the ones that are already defined by the user. You can already create utilities in the same "namespace" as a core plugin, like this:

addUtilities({
  '.w-container': { width: containerWidth, },
});

...but .w-container and its variants will be inserted in a completely different place as the other width utilities in the final CSS:

[user-defined width utilities]
[variants of user-defined width utilities such as hover, active, children, etc.]
[user-defined height utilities]
[variants of user-defined height utilities]
...
[plugin-defined width utilities]
[variants of plugin-defined width utilities]

...which matters if you're using variants that depend on the CSS order rather than specificity.

Having a way for a plugin to add a value to a core plugin (in this case, width) would maintain the expected CSS order for each property:

[all the width utilities]
[variants of all the width utilities]
[all the height utilities]
[variants of all the height utilities]
...

Another argument for this is if a core plugin ever changes its class names, say from w- to width-, plugins that add width values won't have to be updated. They will automatically follow the new format.

I suppose I don't have a strong use case for this, and it's possibly a lot of work to support something like this in the current architecture, so maybe it's not worth it. Just thought I'd throw the idea out there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions