Some way to either parse class names or create class names with custom prefix #15555
Replies: 1 comment 1 reply
-
Hello, Current Approach and Workarounds javascript Custom Utility in JavaScript javascript // Example usage Fork Tailwind and Expose candidate.ts Clone the Tailwind repository. Why Candidate Parsing Is Complex Would you like guidance on submitting a formal feature request to the Tailwind team or expanding on any of these solutions? Best Regards |
Beta Was this translation helpful? Give feedback.
-
I am trying to integrate tailwind into our codebase and i want to make sure tailwind can work alongside what we already have. As a result, we need to have the prefix appended to class names(example: tw-p-4).
While it is trivial to have developers at my workplace ad the prefix manually, it is annoying for them, and they are entering it through something that will pass through javascript, so I have the opportunity to add that prefix in code. The problem I have run into is that the way in which prefixes is added can be somewhat complex to automate without parsing the code entirely.
The tailwind codebase of course parses these class names in the candidate.ts file, but this is not exposed on the package on NPM, so I have no way of using it to create my own class names.
My ask is this: Can we expose the candidate.ts file or some kind of function to programatically add in this prefix. I feel like this would help substantially.
There is a library on npm that does something similar but is maintained by a third party and doesn't cover all cases, so something first party would be nice:
https://www.npmjs.com/package/@xengine/tailwindcss-class-parser
Oh, and the obligatory: These opinions are my own and are not representative of my employer.
Beta Was this translation helpful? Give feedback.
All reactions