what is the correct way to use prefix in tailwindcss

i'm working on a plugin for a certain application, that allows for custom css and whatever. i'm trying to isolate all my css from the other plugins, for isolation purposes i tried using the prefix in the config, but imo it makes it unreadable.
<div className="plug-tg-flex plug-tg-flex-col plug-tg-gap-2">
<div className="plug-tg-flex plug-tg-flex-col plug-tg-gap-2">
But it looks ugly and unreadable
i was thinking of making my own little function that sits in between classname and my actual css like clsx so it will identify tailwindcss classes and adds the prefix to it and it will look like this
<div className={csx("flex flex-col gap-2")>
<div className={csx("flex flex-col gap-2")>
the function is in the utils and have access to the tailwind config and prefix
ok now the problems... 1- I don't have a function that is exposed from the tailwind library that allows me to identify tailwind classes (not sure) 2- tailwind wont recognize the classes and build them because it doesn't find ex plug-tg-flex it found flex (maybe there is a hack for it? idk) PORS: - you don't have to change your entire codebase just to change the prefix - readable code CONS: - every classname will need to be wrapped in the csx function, for consistancy
1 Reply
haitam
haitam6mo ago
i also thought of having a vscode plugin that hides the prefix or make it look smaller ... or as a capsule