Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Tailwind for admin panel

default discord avatar
sejden6 months ago
7

Hi! Is there a way I can use Tailwindcss for components inside the admin panel?



Currently trying with this inside

payload.config.ts

:


export default buildConfig({
  admin{
    css: path.resolve(__dirname, "admin/style/global.css")
  },
  …
})


Should it be done differently?



It worked after cleaning the cache. Thanks!



Hi

@351983077423185921

! You have to disable the Tailwind preflight, as it overwrites the Payload styles if active.


https://tailwindcss.com/docs/preflight#disabling-preflight

Hm. Not sure why that could be happening. Try narrowing it to a Minimal Reproducible example and it might be easier to debug

  • discord user avatar
    jmikrut
    2 years ago
    @281120856527077378

    funny, we were just talking about this



    you should be able to do that

    @668622626041757706

    I've never used Tailwind but loading up extra CSS like that is done exactly how you're attempting to do it



    also, if it's not showing / working for you, try to

    rm -Rf node_modules/cache
  • default discord avatar
    ysione2 years ago
    @668622626041757706

    Hi, I want to use tailwind for panel too but when I add it, it breaks some of payload styles


    Did you encounter the same problem?



    Great, thank you that helped though table still have issue, I think one line of css should fix it or there something else I missing?



    Found the issue, for some reason after build css file had class table which sets

    display:table

    , other than that all good, thank you for your help



    Sorry, can't recall it, but I believe that I had a string as one of the props for component that had a "table" in it, so tailwind parser counted it as class, thats why it was in compiled file, I just renamed the string


    Maybe there is something similar

  • default discord avatar
    iamprompt2 years ago

    I found that it would be a little bit strange if we use TailwindCSS with PayloadCMS. The default root size for TW is 16px while the payload is 13px. TW is base on rem size so that the size we use for tw in payload is not the same as we normally do in others application.



    @364124941832159242

    Is it possible to override the css both components and layout in one file without using !important?? Since I see payload use a separate scss file for each component. I'm not sure, if I rewrite the css with the existing class it would work or not?



    I think many issues are based on the preflight that we skip. Such the border, addition to the

    border

    and

    border-black

    , you need to add

    border-solid

    for the border to show up. If not, it just shows nothing.

  • default discord avatar
    vaunblu2 years ago

    What did you change in order to get the table width to show properly?



    Was it somethings in globals?

  • default discord avatar
    nonfungibletunji2 years ago

    Any tailwind best practices? I would like to use tailwind instead .scss

  • default discord avatar
    alexanarcho7 months ago

    bump, also interested in just adding tailwind to admin panel with out destroying the rest (using the latest 3.0 beta)



    was able to solve this by following this post:

    https://payloadcms.com/blog/how-to-setup-tailwindcss-and-shadcn-ui-in-payload
  • default discord avatar
    whitesniperr7 months ago

    You can add prefix for your tailwind to avoid mess up the predefined css from payload

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.