Add support for literal values in --value('…') and --modifier('…')#17304
Merged
RobinMalfait merged 7 commits intomainfrom Mar 20, 2025
Merged
Add support for literal values in --value('…') and --modifier('…')#17304RobinMalfait merged 7 commits intomainfrom
--value('…') and --modifier('…')#17304RobinMalfait merged 7 commits intomainfrom
Conversation
Contributor
|
Can we either add these to suggest() or make a note to do so later? |
Member
Author
@thecrypticace good idea, added support for that 👍 |
| values.push(value) | ||
| } | ||
| for (let value of designSystem.theme.keysInNamespaces(valueThemeKeys)) { | ||
| values.push(value.replaceAll('_', '.')) |
Contributor
There was a problem hiding this comment.
Didn't we drop the .replaceAll(…) thing elsewhere in the codebase or no? I forget… I just remember something about that changing at some point
Member
Author
There was a problem hiding this comment.
Hmm maybe? I copied it from the existing suggestions. Have to double check if this actually still matters or not. 🤔
Member
Author
There was a problem hiding this comment.
Yep is covered in the suggest function itself.
de461cb to
ca655f4
Compare
This was removed earlier, see `suggest()` function itself.
thecrypticace
approved these changes
Mar 20, 2025
RobinMalfait
added a commit
that referenced
this pull request
Mar 20, 2025
…17308) This PR adds suggestions to CSS based functional utilities when the `--spacing(…)` function is used. Given this 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)); } ``` And this 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 Then you will see the following suggestions: ```json [ "with-custom-spacing-custom", "with-integer-spacing-0", "with-integer-spacing-1", "with-integer-spacing-2", "with-integer-spacing-3", "with-integer-spacing-4", "with-integer-spacing-5", "with-integer-spacing-6", "with-integer-spacing-7", "with-integer-spacing-8", "with-integer-spacing-9", "with-integer-spacing-10", "with-integer-spacing-11", "with-integer-spacing-12", "with-integer-spacing-14", "with-integer-spacing-16", "with-integer-spacing-20", "with-integer-spacing-24", "with-integer-spacing-28", "with-integer-spacing-32", "with-integer-spacing-36", "with-integer-spacing-40", "with-integer-spacing-44", "with-integer-spacing-48", "with-integer-spacing-52", "with-integer-spacing-56", "with-integer-spacing-60", "with-integer-spacing-64", "with-integer-spacing-72", "with-integer-spacing-80", "with-integer-spacing-96", "with-number-spacing-0", "with-number-spacing-0.5", "with-number-spacing-1", "with-number-spacing-1.5", "with-number-spacing-2", "with-number-spacing-2.5", "with-number-spacing-3", "with-number-spacing-3.5", "with-number-spacing-4", "with-number-spacing-5", "with-number-spacing-6", "with-number-spacing-7", "with-number-spacing-8", "with-number-spacing-9", "with-number-spacing-10", "with-number-spacing-11", "with-number-spacing-12", "with-number-spacing-14", "with-number-spacing-16", "with-number-spacing-20", "with-number-spacing-24", "with-number-spacing-28", "with-number-spacing-32", "with-number-spacing-36", "with-number-spacing-40", "with-number-spacing-44", "with-number-spacing-48", "with-number-spacing-52", "with-number-spacing-56", "with-number-spacing-60", "with-number-spacing-64", "with-number-spacing-72", "with-number-spacing-80", "with-number-spacing-96" ] ``` 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds support for literal values inside the
--value('…')and--modifier('…')functions. This allows you to safelist some known values you want to use:E.g.:
This allows you to use
tab-revertandtab-initialfor example.