core: `background` doesn't want to show up (without any errors)
See original GitHub issueIn the playground, I tried adding this:
import { makeStyles, shorthands } from '@griffel/core';
export default makeStyles({
root: {
backgroundColor: 'red',
},
foo: {
background: 'green'
}
});
Expected:
green shows up in the output.
Resulted:
.f3xbvq9 {
background-color: red;
}
Changing background to backgroundColor fixes it. But this was the first thing I tried, and it failed to update or even show an error message. Would be good to expand shorthand.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Forums - CSS - [Solved] Background Image Not Showing
I have the background image saved in the images folder, obviously, as a jpeg. When I go to preview the HTML in Firefox,...
Read more >How to fix CSS background-image not working | HTML/CSS
If the image isn't showing up, but you aren't getting any 404 errors, go into the code inspector and check the element itself....
Read more >swift - Background thread Core Data object property changes ...
The thing is we want to do heavy CoreData task on background thread and reflect the changes in UI on foreground(main thread).
Read more >Troubleshooting Zoom Virtual Background not working
If your virtual background is not showing up when you start a meeting, do the following: Go to Zoom.Us and sign in to...
Read more >Troubleshooting Zoom Virtual Background Issues - Technipages
Sometimes Zoom may fail to add a virtual background or the green screen may not work properly. Use this troubleshooting guide to fix...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I think it’s fine to do that for performance and the css variable nondeterministic reasons, but I think there needs to be feedback to train developers to do the right thing; ideally in the IDE like lint rules which can add red squiggle lines under incorrect syntax with fixers to adjust. In the sandbox, there was no error. It just didn’t work, leaving curious people frustrated and moving on to other solutions.
The ideal would be to “just work” and manage this at runtime, but address performance costs by optimizing at babel transform time. I think that’s possible for expansion; just not for the
padding: --var(--padding)scenario where the caller is providing shorthand values intended for shorthand properties. Maybe that could be avoided by providing helpers around defining variables. (Again some kind of linting, or even runtime name checks that get stripped in production.)I’ve been thinking about it. I think the most ideal would be to do something possibly expensive at runtime, but removable at build time, like:
…basically, call the helper to auto expand for the user so they don’t need to apply extra mental cycles on something they’ve used forever.
If you detect the value is a css variable, maybe you could do something special there:
Then at transform time, expand things and remove the runtime overhead.
Also consider removing the helpers themselves in retail/transformed output.
I think even if there are ts/lint/console errors about the usage, it’s going to create mental headaches for the dev experience. It’s a fine stopgap but the ideal is “it just works”