Skip to content
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

Use a default line height #14503

Open
wants to merge 2 commits into
base: next
Choose a base branch
from

Conversation

MartijnCuppens
Copy link
Contributor

This is a slimmer version of #14335, which only includes the default line heights & the <small> fix.

In this PR:

  • Fixed line heights are replaced by a default line height css function.
  • This removes the need of adding fixed line heights to each font size.
  • It's still possible to use fixed line heights the way it worked before.
  • Custom font sizes will now have a better line height by default. For example, text-[2.4rem] will have a calculated line height of 2.625rem, instead of 3.6rem.
  • The default values are calculated in CSS, which means you can use arbitrary values in combination with custom properties (eg text-[length:var(--title-font-size)]).
  • Relative font sizes like text-[1.5em] or text-[larger] will now use a recalculated line height.
  • Only breaking change is the line height of lg (also see Change line height of the lg font size to 1.625rem #14223).
  • The line heights are always rounded to even pixels (2px), so that you never have vertical alignment issues. Even if you use viewport relative units.

Here's have an overview of which line height will be used for each font size range:

Font size range Line height
0rem - .5rem * 1em
.5rem - 1rem 2em - .5rem
1rem - 2rem 1em + .5rem
2rem - 3rem 2em / 3 + 1rem
3rem 1em

* These font sizes are not used in Tailwind by default

Closes #14484, #14223

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

Successfully merging this pull request may close these issues.

Line-height issue for <small>
1 participant