simple-merge-tailwind-class-names
v1.0.0
Published
Thin wrapper around twMerge and simple-merge-class-names. Basically it's a sanitizer to filter out anything that's not a valid string before passing arguments to twMerge.
Readme
This package is a thin wrapper around twMerge and simple-merge-class-names.
// Pseudo-code
const mergeTailwindClassNames = (...input) =>
twMerge(mergeClassNames(...input));
const mergeTailwindClassNamesDebugger = (...input) =>
twMerge(mergeClassNamesDebugger(...input));Essentially it filters out anything that's not a valid string before passing arguments to twMerge. Crucially it warns about invalid arguments.
Exported functions
| | Warns | Invokes debugger |
| --------------------------------- | ----- | ---------------- |
| mergeTailwindClassNames | ✅ | ❌ |
| mergeTailwindClassNamesDebugger | ✅ | ✅ |
Valid arguments
Valid arguments are:
strings, that are not fully whitespace, these will be the class names you pass.- Empty string
"" nullundefinedfalse
The latter four are valid but will be ignored as they're commonly used in conditional expressions.
Invalid arguments
- Fully whitespace strings
- Objects
- Arrays
true- Symbols
License
This project is licensed under the AGPL-3.0 License. See LICENSE.txt for full details.
