Parameter type of classnames method #211
-
Hello, thank you for making a very useful project. I have one question. can I use classnames to specify styles that only take one string? For example, in the form below. const class = classnames('flex fixed top-0 left-0')
const Comp: React.FC = () => {
return <div classname={class}>...</div>
} If this is not possible as of now, do you've a plan to apply in the future? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Unfortunately I don't think it would be supported because it will require generating every classnames combination which will lead to huge file size and slow autocompletion. classnames('flex fixed top-0 left-0' as TTailwindString) but doing this will cause loss of the type safety and validation of that string. |
Beta Was this translation helpful? Give feedback.
Unfortunately I don't think it would be supported because it will require generating every classnames combination which will lead to huge file size and slow autocompletion.
However you can cast the string to a compatible type:
but doing this will cause loss of the type safety and validation of that string.