Search code examples
javascriptreactjstypescripttailwind-css

Apply TailwindCSS inline styles to components imported from a library


I am building a React component library using TailwindCSS and I was wondering if there was a way to have the styles for the library's components (in node_modules) get compiled with the consuming app's styles, without having every app have the relative path to the components added to the content field of its tailwind.config.js. Having looked at the docs for presets it seems that if I just add it to the library's preset just it gets overwritten by the app's custom config.


Solution

  • I ended up doing what @Wongjn suggested, and created a function that modifies a custom Tailwind config to add the module to the content field.