Remove hash from the default identifier #1534
-
Hello, TL;DR I cannot remove the hash from the default identifier Given the following code: const vars = {
container: {
color: createVar(),
},
};
const rootClassNames = style({
vars: {
[vars.container.color]: 'blue',
},
borderColor: vars.container.color,
}); The generated CSS var will be: I want to customize this identifier to remove the trailing hash, resulting to But the params in the formatting function are: How can I get the original var name |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
You could remove the hash by using a regex like |
Beta Was this translation helpful? Give feedback.
-
This is sort of related to #1228. I haven't had time to think about a proper solution to that issue just yet. However, it seems like you simply want stable, meaningful variable names, rather than just debug IDs. Debug IDs also contain part of the file name, so they aren't exactly stable. Is |
Beta Was this translation helpful? Give feedback.
Also, what do you mean by "on a component basis"? If you want to have predictable variable names for each component, then you can do that with
createGlobalThemeContract
. All it returns is an object mapping keys to variable names, so there's nothing stopping you from using it in a separate.css.ts
file for each component.For example:
You can customize this to your liking, adding in any prefixes/suffixes/fo…