Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

with-tailwindcss example double include of globals breaks styling #1809

Closed
kriswuollett opened this issue Aug 30, 2022 · 3 comments
Closed
Labels
area: examples Improvements or additions to examples

Comments

@kriswuollett
Copy link

What version of Turborepo are you using?

1.4.3

What package manager are you using / does the bug impact?

Yarn v1

What operating system are you using?

Linux

Describe the Bug

The shared ui component includes tailwindcss globals overrides the sample app's globals.css, when both are included in the app. This can cause issues like masking a button's background color (also breaks the search bar layout in the Card layout with sidebar example). Note the missing teal "Send money" button that should be next to "Add money" on the right hand side, and the order of css imports is user agent, global, global, styles:

image

Expected Behavior

The examples should show proper reuse of tailwind/css in a shared UI package.

I'm not sure what the best solution is, but perhaps in the short term it includes:

Longer term perhaps:

  • app should demonstrate extending the theme from ui, e.g., more theme colors

To Reproduce

Not sure at the moment, because merely adding something like the following to the examples index.tsx below the current button seems to work due to the differing import order:

        <div className="mx-auto mt-5 max-w-xl sm:flex sm:justify-center md:mt-8">
          <button className="text-white bg-gray-600">HI</button>
        </div>

Note order of CSS imports is: user agent, globals, styles, globals.

image

@linkb15
Copy link

linkb15 commented Nov 29, 2022

Tailwind Prefix Config

How about prefix the classname so it does not conflicting using the tailwind configuration prefix option?

@tknickman
Copy link
Member

@kriswuollett we ended up using the prefix option for the ui lib in our tailwind example to avoid this issue. The example is up to date now and should fix this!

@kdb13
Copy link

kdb13 commented Feb 1, 2025

@kriswuollett we ended up using the prefix option for the ui lib in our tailwind example to avoid this issue. The example is up to date now and should fix this!

Won't prefixing cause having duplicate classes in the final CSS bundle for the NextJS app?

Suppose, we are using the px-4 class in the ui package as well as the web NextJS app, then when the app is built, it'll include two classes:

  • px-4 from the NextJS
  • ui-px-4 from the UI package

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: examples Improvements or additions to examples
Projects
None yet
Development

No branches or pull requests

5 participants