Skip to content

Instantly share code, notes, and snippets.

@fucksophie
Created May 18, 2024 08:19
Show Gist options
  • Save fucksophie/c0d466cebf4a30c5b5fa2f8c36d4f89b to your computer and use it in GitHub Desktop.
Save fucksophie/c0d466cebf4a30c5b5fa2f8c36d4f89b to your computer and use it in GitHub Desktop.
combine two lists of tailwind classes
function combineTailwind(first, second) {
const secondSplit = second.split(" ")
let classes = [];
const secondIds = secondSplit.map(z => z.split("-")[0]);
for(const defaultClass of first.split(" ")) {
if(!secondIds.includes(defaultClass.split("-")[0])) {
classes.push(defaultClass);
}
}
return classes.concat(secondSplit).join(" ")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment