Giter Site home page Giter Site logo

Tailwindcss Integration about pbandj HOT 15 CLOSED

AlexMNet avatar AlexMNet commented on May 23, 2024
Tailwindcss Integration

from pbandj.

Comments (15)

moishinetzer avatar moishinetzer commented on May 23, 2024 3

@Jared-Dahlke here is an example of implementing tailwindcss. Look at the diff between the init commit and the latest commit to see how I implemented it:

https://github.com/moishinetzer/pbandj-withtailwind

I've been thinking a bit and I think the future is this:

Bundling with bun, by default loading all shadcn/ui components.

But, that would be a completely different project, so I will have a separate repo for this. I think this is interesting to most people, so upvote this comment if you would like to see something like this in the future.

from pbandj.

moishinetzer avatar moishinetzer commented on May 23, 2024 1

Hey Alex!

I'm still considering an extendable way to integrate Styling libraries (MUI, Tailwind etc.)

For now, use tsup's inbuilt postcss integration; you can read up about it on their documentation.

Follow this tailwind installation tutorial, which was made for vite but works perfectly fine for any PBandJ library.

Make sure to import the CSS file with the tailwind directives into your main index.ts file, and for now, remove the css-check script in package.json (or even better, make it skip index.ts)

After doing this, everything just works meaning you can publish your library, and users will have those styles shipped with it.

Note: those styles that tailwind generates will be shipped to the user, but it's unlikely they have their own pb-3 class etc. So it should be completely fine to do so, in my opinion. But again, remember this caveat.

from pbandj.

moishinetzer avatar moishinetzer commented on May 23, 2024 1

Mantine is even easier than tailwind! Check this quick example package I made. You can install it with

npm i compwithmantinee

It only exports a single component Button, and it works totally fine in any project. Make sure to wrap all exported components in theMantineProvider component

(P.S. If you publish your component library open an issue to be added to the main repo!)

from pbandj.

AlexMNet avatar AlexMNet commented on May 23, 2024

@moishinetzer this is great! Thank you so much!

from pbandj.

enyelsequeira avatar enyelsequeira commented on May 23, 2024

Hey Alex!

I'm still considering an extendable way to integrate Styling libraries (MUI, Tailwind etc.)

For now, use tsup's inbuilt postcss integration; you can read up about it on their documentation.

Follow this tailwind installation tutorial, which was made for vite but works perfectly fine for any PBandJ library.

Make sure to import the CSS file with the tailwind directives into your main index.ts file, and for now, remove the css-check script in package.json (or even better, make it skip index.ts)

After doing this, everything just works meaning you can publish your library, and users will have those styles shipped with it.

Note: those styles that tailwind generates will be shipped to the user, but it's unlikely they have their own pb-3 class etc. So it should be completely fine to do so, in my opinion. But again, remember this caveat.

Hello, I am wondering this, is there a way to integrate 2 different libraries, for example I myself want to use mantine and then tailwind, the tailwind part its simple, just wondering about mantine.dev

from pbandj.

AdonaiRdmeek avatar AdonaiRdmeek commented on May 23, 2024

That's great project to integrate with 👍

from pbandj.

Jared-Dahlke avatar Jared-Dahlke commented on May 23, 2024

hey do you guys have an example repo with tailwind working? im trying to use this for a shadcn library but can't get the tailwind styles to apply

from pbandj.

moishinetzer avatar moishinetzer commented on May 23, 2024

Hey Alex!

I'm still considering an extendable way to integrate Styling libraries (MUI, Tailwind etc.)

For now, use tsup's inbuilt postcss integration; you can read up about it on their documentation.

Follow this tailwind installation tutorial, which was made for vite but works perfectly fine for any PBandJ library.

Make sure to import the CSS file with the tailwind directives into your main index.ts file, and for now, remove the css-check script in package.json (or even better, make it skip index.ts)

After doing this, everything just works meaning you can publish your library, and users will have those styles shipped with it.

Note: those styles that tailwind generates will be shipped to the user, but it's unlikely they have their own pb-3 class etc. So it should be completely fine to do so, in my opinion. But again, remember this caveat.

@Jared-Dahlke Have you tried going through these steps? I was thinking about porting this to integrate just with shadcn/ui which I might do soon. Try following these steps and it really should just work.

from pbandj.

Jared-Dahlke avatar Jared-Dahlke commented on May 23, 2024

from pbandj.

Jared-Dahlke avatar Jared-Dahlke commented on May 23, 2024

fyi to anyone following, i made this PR trying to add tailwind: #42

from pbandj.

Jared-Dahlke avatar Jared-Dahlke commented on May 23, 2024

@AlexMNet @AdonaiRdmeek did you guys get this working? Do you mind posting an example?

from pbandj.

AlexMNet avatar AlexMNet commented on May 23, 2024

Hi @Jared-Dahlke sorry I actually didn't end up working with this as I had some other pressing projects to attend to.

from pbandj.

Jared-Dahlke avatar Jared-Dahlke commented on May 23, 2024

@moishinetzer how do i implement this? I notice there is no .css file in /dist.

Should tailwind be installed in the consumer app?

from pbandj.

moishinetzer avatar moishinetzer commented on May 23, 2024

Well that's the beauty it's all injected when the package is imported. Please read through all the docs all of this is expanded there.

from pbandj.

Jared-Dahlke avatar Jared-Dahlke commented on May 23, 2024

this works flawlessly. thank you!!!

I just added shadcn it was pretty easy as expected. I think the tricky part was just getting tailwind to work properly. But yes, i just spent weeks trying to get to this point. There are a handful of other shadcn starter npm libraries out there but none of theme do all of the following:

work with nextjs (app and pages) and vite
tree shaking
consumer app doesn't have to have tailwind installed
types flow through

from pbandj.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.