Skip to content

[v4] preflight removed margins conflicts with web-component :host styles #15864

Open
@nilshelmig

Description

@nilshelmig

What version of Tailwind CSS are you using?

v4.0.0

What build tool (or framework if it abstracts the build tool) are you using?

@tailwindcss/vite@4.0.0, vite@6.0.11, @material/web@2.2.0

What version of Node.js are you using?

v22.9.0

What browser are you using?

Firefox 134.0.2, Chromium 132.0.6834.83

What operating system are you using?

Kubuntu 24.10.

Reproduction URL
https://github.com/nilshelmig/tailwindcss-4-webcomponents-bug

npm ci
npm start

Describe your issue

We use material web-components in our project. While upgrading to tailwindcss-v4 we encountered wrong paddings of buttons and wrong position and size of dialog boxes.

It seems because of preflight setting padding and margin for every element * to zero, it overrides the styling rules from :host of the custom-web-elements.

Currently, the only workaround I see is to create a custom preflight, so that setting padding and margin won't apply to :host elements, or set the padding and margin for the custom element with tailwindcss. The later one would mean more control on our side, but we have to reapply every sizing of material web-components 😕

With preflight enabled
Image

With preflight disabled
Image

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