-
|
I am trying to make a custom utility that behaves similar to any of the spacing related utilities we have by default, like padding, margin, or gap. For these utilities, you should be able to supply an integer that corresponds to Tailwind's spacing scale, or provide arbitrary values: <div class="p-4"></div>
<div class="p-[13px]"></div>What I am trying to do is set a @utility min-width-* {
min-width: min(100%, --value([length], [percentage]));
min-width: min(100%, --spacing(--value(integer)));
}but I believe I should also be able to do it as a one-liner like: @utility min-width-* {
min-width: min(100%, --value(--spacing-*, [length], [percentage]));
}which seems to follow the docs from https://tailwindcss.com/docs/adding-custom-styles#functional-utilities exactly. However, I can only get the first version to work. Am I doing something wrong, or is this possibly a bug? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
|
You are not doing anything wrong and it is not a bug.
|
Beta Was this translation helpful? Give feedback.
You are not doing anything wrong and it is not a bug.
--value(--spacing-*)is a theme token "look-up". However by default, Tailwind has no theme tokens under--spacing. So for the bare value with just an integer, you need to use--spacing(--value(integer))to get the spacing scale.