01brett
Joined 5 years ago
Joined 5 years ago
When I was working through some of the component structures and spacing, the designer explained to me which Tailwind values he used most often and in what scenarios. For example, spacing around sections/containers was 24px or p-6; spacing within sections (like between form inputs) was 12px or p-3; and spacing within elements (like between button icon and text) was 6px or p-1.5.
While these were not absolutes in the redesign, they greatly sped up my scaffolding and allowed my first passes to be either dead-on or close enough to reason about. And when it was close enough (but not dead-on), toggling up or down a value usually settled it to match the mocks.
Personally, this was the easiest time I've had for getting an implementation "pixel perfect." I chalk this up as a design system win more than Tailwind. Any well-defined design system would open up these collaboration benefits. I found Tailwind to be an asset to these both for my own DX and for collaboration with my designer. I think Theme UI or styled-components could fit that goal just as well.
https://github.com/facebook/create-react-app/milestone/81?cl...
const sharedStyles = "..."
and in my component combine the shared with the unique attributes <CoolComponent className={`${sharedStyles} py-3`} />
or using a string combiner utility like classNames/clsx <CoolComponent className={clsx(sharedStyles, "py-3")} />
If you have a props to change on, you can do this <CoolComponent className={clsx(sharedStyles, someProp ? "py-3" : "py-4")} />Also, if you have written about your design system implementation with CSS Modules and CSS variables, I'd love to read it.
[0] https://tailwindcss.com/docs/extracting-components#extractin...
The Tailwind docs get into it a bit as you can see here: https://tailwindcss.com/docs/configuration#theme
Here is the spacing section in my config where I've extended the default with interstitial values. What's really cool is these propagate to all the spacing utilities (padding, margin, margin between, etc)