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

Reset letter spacing for form elements #13150

Merged
merged 4 commits into from Mar 22, 2024

Conversation

Stadly
Copy link

@Stadly Stadly commented Mar 8, 2024

Some browsers, such as Chrome, set letter-spacing: normal for form elements. For consistency with the other styles, it should be set to inherit by Preflight.

Currently, for <div class="text-sm"><textarea>hello</textarea></div>, the <textarea> will inherit the font-size and line-height, but not letter-spacing. This PR fixes that.

Some browsers, such as Chrome, set `letter-spacing: normal` for form elements. For consistency with the other styles, it should be set to `inherit` by Preflight.
@adamwathan
Copy link
Member

Hey! Can you share a real example of where this would have been helpful? I believe it exists but always helpful to see the practical motivation 👍

@Stadly
Copy link
Author

Stadly commented Mar 18, 2024

Sure. Sorry for the delay. Here is an example: https://stackblitz.com/edit/sveltejs-kit-template-default-fwqbwb?file=tailwind.config.js

Notice how font-size and line-height is inherited by the <input> elements, while letter-spacing is not.

@adamwathan
Copy link
Member

Thanks! What I mean though is can you share a real design you needed to build where this was important and you ran into unexpected results without this change?

@Stadly
Copy link
Author

Stadly commented Mar 18, 2024

Ah. For example in a simple to-do application, where you enter a new task in an <input> element and press enter to add it to the list as an <li> item. If ther developer is not aware of letter-spacing not being inherited by <input>, there will be an inconsistency between the appearance of the task before and after pressing enter. Since large values are not common for letter-spacing, it is likely that the inconsistency might go unnoticed during testing, but still impact user experience negatively.

It is of course not a big issue - it will usually be a small difference in appearance, and it can be fixed by applying the relevant text-... class to the <input> element, but I still think this is a surprising behavior and a tiny pit fall that would be nice to have mitigated :)

@thecrypticace thecrypticace self-assigned this Mar 22, 2024
@thecrypticace thecrypticace merged commit ea90d3a into tailwindlabs:master Mar 22, 2024
13 checks passed
@thecrypticace
Copy link
Contributor

Thanks!

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.

None yet

3 participants