-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support css property #6
Comments
While I can see the cleanliness benefits, especially when used alongside a For fairness, I'll compare a before and after of this feature with some examples. With just a CSS prop: // before
<span tw={css({ color: theme('colors', 'blue.500') })}>Blue</span>
// after
<span css={{ color: theme('colors', 'blue.500') }}>Blue</span> I don't think there's a huge DX upgrade here 🤷♂️ not much more to say With a CSS prop + tw prop: // before
<span tw={`font-bold ${css({ color: theme('colors', 'blue.500') })}`}>Blue</span>
// after
<span tw="font-bold" css={{ color: theme('colors', 'blue.500') }}>Blue</span> Shorter, and less noisy by a considerable amount. I also like the ergonomics. With the first example, I had to convert to a template string before adding an extra class/css, but the second one, I just needed to add a new prop. The second example does have me thinking it may be worth, but I also don't really hate converting to template strings either. Keeping it all in one prop I feel simplifies the mental model a bit. I can see arguments both ways |
That sounds all fair. Most (styled) CSS-in-JS support such a property. It is meant as a compat layer. But I acknowledge your points. One other point for the |
I'm raising this mostly to have the same API with @twind/preact. Whether we support it or not we should aim to align both JSX like libraries. Should have talked to you before releasing @twind/react. |
Totally agree, and no worries, we have a lot of room to move in pre-beta (even though the JSX preprocessors have major releases; I just don't like major 0 versions 🤷)
🤔 Also good points, though the savings only apply if they don't use any additional As for a potential migration path, a codemod is an idea I've had floating around my head. I've often done some simple regex replaces to convert from |
The
css
property could be used to pass arbitrary CSS objects.Output
References:
The text was updated successfully, but these errors were encountered: