Add suggestions when --spacing(--value(integer, number)) is used#17308
Add suggestions when --spacing(--value(integer, number)) is used#17308RobinMalfait merged 4 commits intomainfrom
--spacing(--value(integer, number)) is used#17308Conversation
8a00834 to
d54b2d0
Compare
Output is based on the result of: CSS: ```css @import "tailwindcss"; @theme { --spacing: 0.25rem; --spacing-custom: 123px; } @Utility with-custom-spacing-* { size: --value(--spacing); } @Utility with-integer-spacing-* { size: --spacing(--value(integer)); } @Utility with-number-spacing-* { size: --spacing(--value(number)); } ``` HTML: ```html <div class="with-custom-spacing-custom"></div> <div class="with-custom-spacing-0"></div> <div class="with-custom-spacing-0.5"></div> <div class="with-custom-spacing-1"></div> <div class="with-custom-spacing-1.5"></div> <div class="with-integer-spacing-custom"></div> <div class="with-integer-spacing-0"></div> <div class="with-integer-spacing-0.5"></div> <div class="with-integer-spacing-1"></div> <div class="with-integer-spacing-1.5"></div> <div class="with-number-spacing-custom"></div> <div class="with-number-spacing-0"></div> <div class="with-number-spacing-0.5"></div> <div class="with-number-spacing-1"></div> <div class="with-number-spacing-1.5"></div> ``` Play: https://play.tailwindcss.com/tYDaSNiNtS
- When `--value(--spacing)` is used, then `--spacing` theme key suggestions will be used. - When `--spacing(--value(integer))` is used, then `--spacing` scale suggestions will be used, but _only_ for `integer` values. - When `--spacing(--value(number))` is used, then `--spacing` scale suggestions will be used, but for all values.
d54b2d0 to
ae89775
Compare
|
@RobinMalfait (sorry, probably trivial...) Sorry for the trivial noob questions; but I'm having a hard time wrapping my head around the new plugin system and want to make sure that it's not working for me, because it just can't yet :D:D – Any way for me to see if this PR has been released yet? EDIT: Also I don't quite get why your HTML examples show EDIT2: Also also :D – cool that this system easily allows to only suggest custom values <3 EDIT3...: It feels a bit odd that both |
Correct it's not yet released. You have to be on the insiders build in order to get suggestions. If you switch the Play link to use the insiders version it should work. See: https://play.tailwindcss.com/VaNteSLX3A
Yep, checkout the CHANGELOG.md file for this: https://github.com/tailwindlabs/tailwindcss/blob/main/CHANGELOG.md#unreleased
I just copied the 3 types of plugins with the exact same values. Then verified what actually got generated (see Generated CSS tab at the bottom). Let me annotation it for you: https://play.tailwindcss.com/ZiGsqoXgwV
It is a bit odd, but this is how CSS defines custom functions, they just look like a CSS variable.
In this case
Yes, should already be the case:
Correct, just need to be on the correct version 😁
|
|
@RobinMalfait I'm sorry to bother you again, but I'm about to pull my hair out.. Proof I have the correct version of tailwindcss Copy and pasted the exact utility you used Proof that the utility is being loaded and does what its supposed to do But still without any suggestions :O Do you have any idea what's going on here? |
|
Hmm, can you reproduce it in a small reproduction repo and share it? |
You are too good and thorough! I "solved it" (it rather solved itself) – but you were too quick to reply; so now I can't delete my comment. What did change? Honestly... I don't know for sure, but after clearing npm cache, removing node_modules, package-lock.json to reoslve an unrelated peer dependency... its now working! 🤷 Thanks for the very quick reply and your willingness to help <3 – much appreciated |











This PR adds suggestions to CSS based functional utilities when the
--spacing(…)function is used.Given this CSS:
And this HTML:
Play: https://play.tailwindcss.com/tYDaSNiNtS
Then you will see the following suggestions:
This is because
--spacing(--value(number))will include all default spacing scale suggestions we use. And--pacing(--value(integer))will include the same list but without the floating point numbers.Follow up PR for: #17304