-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature proposal] configurable class names #523
Comments
Coming from using Tachyons, I like the fact that Tailwind allows you to customize the values since it can cover more bases than Tachyons alone can. However, I think I prefer Tachyons' terse class names over the verbose ones here. Still, one advantage of not adding this feature is that multiple companies/parties are forced to use the same "language" to refer to the same concepts. If I work at company X who use Tailwind and then start working for company Y who also uses Tailwind, when scanning the code base for company Y, I already know that |
I understand that a consistent naming scheme can be an advantage for a framework. The main reason I wanted a way to configure every class is beyond the realm of naming preferences. The possibility to cater the framework class naming to your public can be a big argument to convince people to start using a more technical solution for their problems, without adding too much mental overhead. |
I can see how that would be really helpful for people who aren't developers. Also, one other question. Let's say I wanted to configure the .tracking-X { } becomes .tr-X { } Or we are talking about a one-can-be-aliased-by-another relationship? .tracking-X { } becomes .tracking-X, .tr-X { } The first one implies that only one name can be used throughout the entire code base whereas the second means a developer who is familiar with Tailwind can use Granted, I'm not sure how this second approach would affect performance, nor whether it would cause more problems because now an |
We might make this possible eventually but it's really low priority. In the mean time, you could always write a plugin that generates the same CSS as an existing module but with a different class name, and then disable the built-in module in the modules section of your config file: // ...
modules: {
// ...
- tracking: ['responsive'],
+ tracking: false,
// ...
}
// ... The plugin itself would look like this: import _ from 'lodash'
export default function(variants) {
return function ({ addUtilities, config }) {
const utilities = _.map(config('tracking'), (value, modifier) => {
return defineClass(`ls-${modifier}`, {
'letter-spacing': `${value}`,
})
})
addUtilities(utilities, variants)
}
} |
@JordanMartinez my solution is of the one-is-replaced-by-another type. The reason is that marketeers don't care about which technology you use, as long as they can be more productive everything is fine. I mentioned that Tailwind provides a way to change classes. But if you have to change a lot of classes, it's too much boilerplate. I'm going to make an effort to keep my fork up to date, so that other people can use it. |
@adamwathan Thanks for the snippet! @xwero Ah... yeah, that would create problems. Also, I guess even the name-change decision (type alias or replacement) could be defined for each module. |
I think there is some merit to allowing custom class names in Tailwind core that's possibly being overlooked, related to semantic naming. For example, having semantic text color names like: Then you'd be able to generate classes as such: |
No concrete plans to support this so going to close for now. |
This would be helpful as I have another 3rd party library that uses !important in their class and has the same name as a tailwind css class. Therefore it overrides the tailwind class whenever I try to use it. I guess I'll look into the plugin system in issue #102. |
I'd like this to make Tailwind more concise. Things like It'd be extra useful for variants--imagine how much space you can save typing |
I read the #102 issue for custom class names. But I found the solution a bit lacking.
If you want to change one class from a plugin, you need to copy paste the plugin and add the change. And what if you want to change 20 plugins?
So I forked the project and came up with a way to make all classes configurable. https://github.com/davidDuymelinck/tailwindcss
Basically I added a new key to the config object, modifyClassNames. The value of the key is an object which has the module names as keys.
Each module has a prefix and modifier key. The prefix has a string value. The modifier key is an object with a key from the plugin and as value the class name after the prefix.
This example is for the class name that is now generated as break-normal.
For the modifier keys I wanted to stay as close to the style value as possible to make the configuration as easy as possible. An other example of this is the
noDecoration
key for the current class name no-underline.I understand this is a nice to have for the maintainers. I just wanted to show the solution I came up with, to find out if there are other people who still want class name configuration included in Tailwind CSS?
The text was updated successfully, but these errors were encountered: