Named border widths #16875
timomihaljov-yle
started this conversation in
Ideas
Named border widths
#16875
Replies: 1 comment 2 replies
-
If it helps, you can defined named @theme {
--border-width-sm: 1px;
--border-width-md: 2px;
--border-width-lg: 3px;
} |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Our design system uses named border widths (
sm
,md
,lg
) and I'd like to use these same names in our Tailwind utilities (e.g.border-x-md
), only referring to concrete values using the arbitrary value syntax (e.g.border-x-[13px]
) to make it clear that we're stepping outside the design system knowingly and not by mistake. This was possible in v3 with custom configuration:Ideally I'd like to do the same thing in v4:
Unfortunately it seems that v4 only supports concrete border widths like
border-x-3
, and I haven't found a good workaround. Using custom properties for the names would require the quite unnatural-looking syntaxborder-x-(length:--border-md)
while leaving the nicer syntax for concrete values, which is the opposite of what I want.As another option I considered using
@utility
to define custom versions of the utilitiesborder-*
,border-x-*
, etc. but writing a dozen or so utilities by hand is exactly the kind of work I'd like to avoid by using Tailwind, and it would still allow the use of classes likeborder-x-3
, which I'd like to discourage.Can you please consider adding a new theme variable namespace,
--border-*
(or--border-width-*
), for this use case? I think--spacing-*
sets a nice precedent: it works with arbitrary numbers by default but can be reset with--spacing-*: initial;
to only work with an explicitly defined scale that may include named values.Other than this small gripe, I'm very pleased with v4 and how seamlessly it integrates with vanilla CSS. Thank you for the great work you've done with Tailwind!
Beta Was this translation helpful? Give feedback.
All reactions