5 ms·
The first thought everyone has when seeing it is what you described, including myself. I suggest trying it out & reading more about it. It's the only way utili
by mattferderer 7y ago
The first thought everyone has when seeing it is what you described, including myself.
I suggest trying it out & reading more about it. It's the only way utility CSS frameworks like this seem to click.
In my opinion, Tailwind works best when being used to create template components. In your button case you would just modify your reusable button component or the reusable base button component if you have multiple button components.
You get the best of all worlds.
* You avoid writing a lot of CSS.
* You don't have to worry about thinking of CSS class names or name pollution
* I find it faster & easier to style components with a utility CSS framework in something like Storybook than it is with CSS.
* I recommend adding a plugin to your editor to help with the names of Tailwinds classes. VS Code has a couple that will suggest the right class name based on what you type.
- Etheryte 7y agoYou get all of those benefits without any of the downsides by using any other modern styling solution, for example scoped styles and scss. The arguments against this solution far outweigh the arguments for it. You're free to disagree, of course.
- adamwathan 7y agoScoped styles and SCSS do not prevent you from having to come up with unnecessary names for things like utilities do. That's the main benefit in my opinion. Wasting brain cycles to name arbitrary wrapper divs that only exist to be a target for layout styles things like ".image-card-content-wrapper" is a completely unnecessary step in the UI development process. Using utility classes to build a UI is much more like building something with SwiftUI, where no one seems to argue about this silly "separation of concerns" thing we talk about on the web.
- Etheryte 7y agoUsing SCSS and using some utility classes isn't in any way mutually exclusive. If anything, it's a lot easier to mix and match. The argument isn't against having utility classes/mixins/extensions in general, but against relying on them solely. I'm still not convinced — using only utility classes has very clear downsides, while using what's reasonably one of the most common approaches in the industry right now avoids those downsides while also providing additional benefits.
- mattferderer 7y agoI don't think you can "only use utility classes". I think they cover 90%+ of your CSS though. I apologize if that came across as the argument I was making. Yes, you probably will need to create some custom classes from time to time. Ideally those might be done in a utility fashion though.