#How do I use an imported image as a Tailwind or CSS Background image?

8 messages · Page 1 of 1 (latest)

midnight blaze
#

I've tried the following but it doesn't work:

`import bg from "~/assets/images/image.jpg";

<style define:vars={bg-url: bg}>
.hero {
background-image: url(var(--bg-url));
}
</style>`

trim forge
midnight blaze
trim forge
midnight blaze
#

oo it worked!

trim forge
#

This also might not be working because images in the /src folder are bundled and renamed, you could try moving your image to the /public folder Nvm

midnight blaze
#

thank you

#

I'm actually passing the data from the template