-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Using Tailwind in Custom Admin Components messes up Admin Collection Table View #11679
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
Comments
Hey @HappyEmu This is because the @layer utilities {
.table {
display: block;
}
} Let me know if that works for you! |
@akhrarovsaid Yes, that fixes this particular problem, thank you ❤ But I'm wondering if this is working as intended since I thought that was exactly the reason why Payload uses their own It was certainly a surprise at our company that we cannot use e.g. ShadCN components as custom components in the admin interface (e.g Sidebar for navigation) without problems. The only guide we get in the docs is:
I wonder how that is supposed to work with Tailwind, maybe I am missing something. Also, this would go against our wish to be able to re-use user facing frontend components in the admin interface. Also, it would be nice to know if https://payloadcms.com/posts/blog/how-to-setup-tailwindcss-and-shadcn-ui-in-payload is still considered valid with the current state of Payload 3.0. |
Just want to mention I lost several hours trying to figure out this bug before finding this thread. Am I doing custom components wrong? Did I break a config somewhere? Should I restyle the parts of the admin that are now broken, or restyle my whole component? This is the anguish devs are going to go through if they don't find this overwrite fix. |
try use this for tailwind, this is how I get my tailwind components to work on payload. Both in dev and in production, using this 'twp' to override things such as h2, h3, h4 classes and p classes for example |
Describe the Bug
When I wanted to add a custom field component to one of my fields in a collection, I want to use Tailwind to style that component. In fact, the component I want to use as a custom Field component is a component that is already used in the user-facing (frontend).
I was mostly successful in integrating the component, but noticed that adding Tailwind as per https://payloadcms.com/posts/blog/how-to-setup-tailwindcss-and-shadcn-ui-in-payload (I know it's outdated) messes up the table widths in the collection views:
With
@tailwind utilities;
inapp/(payload)/custom.scss
With
@tailwind utilities;
inapp/(payload)/custom.scss
Notice how with
@tailwind utilities;
, the table width does not span the full width of the parent container.I'm wondering if the way outlined in above blog post is still the way to integrate Tailwind into custom components. If not, then I certainly have not found a way to do it in the docs and the example at https://github.com/payloadcms/payload/tree/main/examples/tailwind-shadcn-ui still proposes to do it in the same way.
This is easily reproducible by checking out the
website
template ofcreate-payload-app
and adding the Tailwind directives, which is what I did in my reproduction link below.Link to the code that reproduces this issue
https://github.com/HappyEmu/payload-custom-tailwind-component-reprod
Reproduction Steps
@tailwind utilities;
is declared or not.Which area(s) are affected? (Select all that apply)
area: ui, area: templates, area: docs
Environment Info
The text was updated successfully, but these errors were encountered: