Description
Following up on the discussions in #664 and #665, I wanted to create a separate thread to get feedback on the overall idea and the motivation behind it.
One of the big problems I'm trying to solve for Tailwind 1.0 is that I want the core plugin names to be as consistent as possible as well as as guessable/intuitive as possible. You can see a bunch of the work I have done towards that in this pull request: #656
The framework behind the new core plugin naming is:
- Use singular terminology, not plural. It should be "the border color plugin", not "the border colors plugin".
- Match the CSS terminology unless there's a really good reason not to. That's why the "text sizes" plugin is now the "font size" plugin, but "text colors" is "text color" since "color" could be confusing alongside the existing "colors" key that defines your entire color palette.
I hate that in Tailwind 0.x some things are plural, some are singular, some match CSS, and some don't. It feels like there is no naming system at all, just a hodge podge of random bullshit.
For this reason, I really want to rename the leading
and tracking
plugins to lineHeight
and letterSpacing
respectively.
Now to clarify, the plugin name is the key you use to customize the values for a utility in both the theme
(root level in 0.x), variant
(modules
in 0.x), and corePlugins
(n/a in 0.x) sections of your config file.
That is to say that in this example config (1.x format)...
module.exports = {
theme: {
opacity: {
'0': '0',
'50': '.5',
'100': '1',
},
},
variants: {
backgroundSize: ['responsive'],
},
corePlugins: {
objectFit: false,
}
}
...opacity
, backgroundSize
, and objectFit
are examples of plugin names.
On to the challenging part...
I really want the keys in the theme
section to be plugin names, so that they are the same keys you would use in the variants
and corePlugins
sections.
Put another way, I don't want users to customize their fonts by changing theme.fonts
but change which font family variants are generated by changing variants.fontFamily
.
That's why in 1.x, fonts are specified in theme.fontFamily
, even though fonts
might feel like a more natural name for that key in that particular context:
// 🚫 Bad, fonts and fontFamily are used by the same
// plugin but it's not obvious or explicit
module.exports = {
theme: {
fonts: {
heading: { ... },
body: { ... },
},
},
variants: {
fontFamily: ['responsive'],
},
}
// ✅ Good, both sections use the same key so the relationship is clear
module.exports = {
theme: {
fontFamily: {
heading: { ... },
body: { ... },
},
},
variants: {
fontFamily: ['responsive'],
},
}
However, something feels extremely crappy about customizing the leading-*
and tracking-*
classes under lineHeight
and letterSpacing
keys:
module.exports = {
theme: {
// 🚫 Unintuitive if class name is `leading-*`
lineHeight: {
none: '0',
copy: '1.5',
heading: '1.25',
},
// 🚫 Unintuitive if class name is `tracking-*`
letterSpacing: {
none: '0',
copy: '1.5',
heading: '1.25',
},
},
variants: {
lineHeight: ['responsive'],
letterSpacing: ['responsive'],
},
}
If you have already learned to type class names like leading-tight
in your HTML and come to your config file to tweak or add a new value, my gut feeling is that you are much more likely to try adding a leading
key to your theme than you are a lineHeight
key. This is magnified by the fact that in 1.0, your config file will be empty by default, and you will have to add the lineHeight
key by hand the first time you want to customize it.
However, if leading-tight
was something like lh-tight
or lines-tight
, it seems a lot less unintuitive that changes should be made under a lineHeight
key rather than a leading
key.
So here are the questions I have...
(I'm using leading/line-height for all of these examples, but all of this applies equally to tracking/letter-spacing as well.)
-
Is it actually just fine for a plugin name to be completely different from the class names it generates?
Is it really a problem that to add new
leading-*
classes you need to customize thelineHeight
key in your config file? Some other plugins are sort of like this already (theborderRadius
plugin generatesrounded-*
classes, although I'm considering changing that as well). -
Is it actually just fine for the plugin to be called
leading
instead oflineHeight
, so we can just leave everything as-is?What if the keys to control variants and values for line-height are
leading
to match the class name? Is that really weird? It breaks rule Update defaultConfig.js #2 of the naming convention for plugins which is to match CSS unless there's a really good reason not to, but maybe that's not the end of the world? My fear with doing that is that it sets a precedent that plugin names are just picked based on what feels best instead of having any sort of guessable convention, which I worry will make me want to re-examine all of the other existing plugin names as well.
Basically right now I see two options:
-
Rename the
leading-*
andtracking-*
classes to something more likelh-*
/lines-*
andletters-*
, so that usinglineHeight
andletterSpacing
for the plugin names feels more intuitive. -
Keep the classes as
leading-*
andtracking-*
, but also name the pluginsleading
andtracking
even though it breaks my plugin naming system.
Am I wrong for believing these are the two best choices? Does it make more sense to mix the leading
and lineHeight
terminology, where the classes are leading
and the config keys are lineHeight
?
Should I step back even further and re-examine whether or not the keys in theme
actually have to/should match the keys in variants
? Put another way, is this actually as bad of an idea as I think?
module.exports = {
theme: {
// Values are customized under the `fonts` key
fonts: {
heading: { ... },
body: { ... },
},
},
variants: {
// Variants are customized under the `fontFamily` key
fontFamily: ['responsive'],
},
}
There's already a bit of asymmetry there since background colors, text colors, and border colors will be customized using the colors
key 95% of the time, and padding and margin will be customized using the spacing
key.
Somebody please help me 😂