-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
How to use tailwind reset styles with Payload without breaking admin styling #8878
Comments
Oh, it's kind of documented, solved it using: @layer payload-default {
@tailwind base;
@tailwind components;
@tailwind utilities;
}
/* My custom styles */ |
It's not working 100% as hoped. Some payload styles are defined in the payload-default layer, e.g. h1, h2, h3 which means the group field title is affected by loading tailwind. So the challenge is: how to define styles with lower priority than the payload-default layer? How about adding one more layer: |
That could break a lot of styling regardless and I don't want to introduce another layer unless we have to. To double check this, have you tried disabling preflight? This removes the actual resets affecting our styles. |
I have a similar issue is that I had several custom dashboard components made with ShadCN & Tailwind which also breaks the whole admin ui now. Disabling preflights works for the admin part, but it breaks all my custom dashboard components, and frontend unfortunately |
You can leave preflight enabled and then just dont import the |
I want to share components over projects, and also between admin and pages using other layouts. Would you consider refactoring payload styles to depend on BEM and not on the reset? I think it's 95% there. |
That is not going to happen in time for v3 unfortunately. I have some ideas for improving everything here for v4... Did some testing and unfortunately it's basically always going to be the case that something will break when injecting new resets. There is a way to scope the resets with tailwind from this discord thread https://discord.com/channels/967097582721572934/1304542354111205426/1305633796711776256 Using import { scopedPreflightStyles, isolateInsideOfContainer } from 'tailwindcss-scoped-preflight';
...
plugins: [
scopedPreflightStyles({
isolationStrategy: isolateInsideOfContainer(['.useTw']),
}),
], You can then add the I'll update the title of this issue as well so people can land on this solution |
This issue has been automatically locked. |
Describe the Bug
I was loading custom css (@tailwind) using a simple import. The latest update from version 110 -> 117 changed the order that styles are loaded which unstyles the payload Button component.
Link to the code that reproduces this issue
todo
Reproduction Steps
Which area(s) are affected? (Select all that apply)
area: ui
Environment Info
Binaries:
Node: 22.5.1
npm: 10.8.2
Yarn: 1.22.22
pnpm: N/A
Relevant Packages:
payload: 3.0.0-beta.117
next: 15.0.1
@payloadcms/db-mongodb: 3.0.0-beta.117
@payloadcms/email-nodemailer: 3.0.0-beta.117
@payloadcms/graphql: 3.0.0-beta.117
@payloadcms/next/utilities: 3.0.0-beta.117
@payloadcms/plugin-cloud: 3.0.0-beta.117
@payloadcms/richtext-lexical: 3.0.0-beta.117
@payloadcms/translations: 3.0.0-beta.117
@payloadcms/ui/shared: 3.0.0-beta.117
react: 19.0.0-rc-65a56d0e-20241020
react-dom: 19.0.0-rc-65a56d0e-20241020
The text was updated successfully, but these errors were encountered: