Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add experimental extended spacing scale #2141

Merged
merged 1 commit into from
Aug 7, 2020
Merged

Conversation

adamwathan
Copy link
Member

@adamwathan adamwathan commented Aug 7, 2020

This PR introduces a ton of new values to the default spacing scale. This is extracted from the @tailwindcss/ui plugin so it very battle-tested. Keeping it under experimental for now just in case we want to make a change or two.

High level changes are:

  • Adding micro sizes, like p-0.5, p-1.5, p-2.5, and p-3.5
  • Adding min-content and max-content to min-width, width, and max-width utilities
  • Adding max-w-none
  • Adding all of the spacing values to the inset plugin

Only difference vs. the Tailwind UI plugin is that I haven't included max-w-prose. I think the typography plugin can just add that itself via the extend property in the config it provides.

This feature is flagged as extendedSpacingScale in the experimental section:

// tailwind.config.js
module.exports = {
  experimental: {
    extendedSpacingScale: true
  },
 // ...
}

@adamwathan adamwathan merged commit 8f88cf5 into master Aug 7, 2020
@adamwathan adamwathan deleted the extended-spacing-scale branch August 7, 2020 17:26
@anasbouzid
Copy link
Contributor

anasbouzid commented Aug 21, 2020

Micro sizes don't work in the theme() function because of the dot notation. I'm wondering if it possible to return a Sass map/list instead of the default object representation [object Object]? this will allow more flexibility such as map-get(theme('spacing'), '3.5') and may even fix the upcoming theme('fontSize.2xl') issue you mentioned.

edit: I forgot that tailwindcss also supports other preprocessors and even normal css, not sure how to fix those issues.

@adamwathan
Copy link
Member Author

You can use this notation actually: theme('spacing[2.5]')

@kevnk
Copy link

kevnk commented Aug 27, 2020

Interesting idea to add more spacing options... I guess it's up to each developer, but personally, I've found it super helpful to have fewer options. When you use the Golden Ratio for spacing, you have fewer options, but it seems to always have an option that works really well and looks really good.

I haven't really released it, but I've been working on some Golden Ratio utilities:

Check out this 2-minute screen share that briefly explains some benefits of using Golden Ratio spacing: https://www.loom.com/share/4745f99cdf5147b9940b13141ec581b7

A few "in the wild" production projects I've launched that use the Golden Ratio for spacing:

In Summary: I've found fewer spacing options are better/faster/more efficient AND they look better when they're Golden Ratio related. If used for line-height too, it makes a vertical rhythm way more attainable.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants