Open Props: Tailwind Alternative from Chrome Dev Team
open-props.style
open-props.style
However, open-props never mentions tailwind. That simple mis-title has hijacked the convo.
Edit: ...and if they do, I think I just tagged them unnecessarily. xD
https://news.ycombinator.com/newsguidelines.html
The [flagged] marker, btw, is because users flagged the submission, which they were correct to do.
[0] Also, because it's not murky enough, "Chrome Dev" are the DevRel people (community outreach, web.dev articles, conferences, etc), not the "developers of Chrome." https://twitter.com/ChromiumDev
To me the biggest benefit of Tailwind, apart from the great base design system, is not needing to come up with class names for 99% of the things in the app. This is of course only possible when you have some way to abstract components out of the reused parts of your markup – e.g. you're using React.
Edit: The title was "Open Props: Tailwind Alternative from Chrome Dev Team" when I posted this comment.
I agree with you: half of Tailwind's value for me is the scales, and half is that I don't need to create a derivative taxonomy of my app - I just style the thing that needs styling.
However, there's a point in using something like BEM (https://getbem.com/) for your class naming scheme, and go away with the utility classes within your HTML. The utility classes from Tailwind (and Bootstrap) provide great consistency, and this seems to provide the same but from within your SCSS itself.
They did make a companion JIT PostCSS plugin that likely has Tailwind as its forebear.
Tailwind had to come up with something, and that something is it's JIT compiler, because shipping 10mb to the browser in dev was untenable. Let alone the people that never setup purgecss and were shipping that in production.
To me, the main benefit of Taiwind is not choosing arbitrary values. Writing everything as classes in the markup is something I deal with. It's ocasionally really convenient, but a distraction most of the time. This seems to solve exactly that problem. I still get a reasonable consistent set of values to choose, but can still write normal CSS. I'm really looking forward to trying it out.
How do you deal with one of those values needing to change? With SASS or css-in-js you can define a variable and then update it everywhere at once by changing a single line. This seems to be the biggest thing you give up with Tailwind.
The 'update everywhere' was the biggest hurdle for me, particularly with 'design on the fly' quick pieces. But as per the Tailwind docs, generally you're building reusable parts in Vue or whatever, and you change there. There's a page on it here: https://tailwindcss.com/docs/reusing-styles - which I appreciate is still a bit of a 'really?!' kinda thing if you're used to normal CSS.
But to quote The Office... Different drinks for different needs.
However, I've found such a thing mostly unnecessary. Even with Tailwind I have some abstractions at the component layer so that I don't need to change values all over the place when I want my buttons to have more padding. I'd just change `px-2` to `px-4` in that one place where I define my button styles, for example.
If you need to change values dynamically with JavaScript such as you can with CSS-in-JS, I'd typically use CSS variables.
Now of course this isn't as powerful a system as SASS variables, but it's good enough. That is to say, I have gripes with Tailwind still, but dealing with variables isn't one of them.
IMO the main value of Tailwind is that it's a step function over your units and colors, which helps bring better consistency and dev speed to UI implementation.
Tailwind's "write class names instead of CSS" approach makes sense in the component-based systems most apps are built in these days, where pretty much any repeated markup will be turned into a component. It performs better than scoped styles and is less complicated.
A CSS variable approach like Open Props or Pollen is, in my experience, better if you're not using a component-based system (ie. conventional HTML) and therefore have repeated markup patterns. Having a simple class name to apply to repeated markup is much more maintainable than trying to copy/paste a long tailwind string around.
I see it the opposite way, Tailwind is for when you don't care about design system and would like the freedom of ad-hoc styles, that is conveniently already written.
When you do need to IMPLEMENT a design/component based system, you'd prefer css (for less indirection) and have the interface of the system be something like react props where it's more restricted, as opposed to classes like in Tailwind.
So please explain what they are and why they are not overengineering?
The benefit for me of having everything basically be variables is you can quickly modify a site to look like a different one to save time.
I also have, which I think the Chrome people should offer with this, a visual settings editor on the front end for swapping/tweaking styles in real-time.
And makes it easy to import into existing projects and just start using.
That’s interesting.
Whereas if I choose a gradient from https://hypercolor.dev and copy its tailwind code it's something like `bg-gradient-to-br from-pink-300 via-purple-300 to-indigo-400`. I can look at that in my code and form an idea in my head what it looks like, and tweak it trivially.
"How can I make it end at a slightly darker blue etc." -- you're just writing CSS, so just write the CSS you want instead. ie OpenProps is just providing you a CSS variable that expands to something like: `background: linear-gradient(blue, pink);`, and if you want to change it you can just change it.
"--radius-2": unprefixed, in global scope/namespace? I'd rather use scss variables and modules tbh.
There are some limitations to this approach: some of the utility classes encompass several values, and you have to remember to include all of those CSS vars to replicate the class.
Still, I am not sold...
You should apply to buzz feed with these skills.
- HTML
- CSS
- Clickbaiting
- Javascript