-
From issue #539 (comment) I've learned that the only way to reference an image is to use dynamic styles. But the problem then is that const styles = stylex.create({
dynamic: () => ({
backgroundImage: stylex.firstThatWorks(
`var(--paletteTitleBackground), url('${headerJpg.src}')`,
`var(--paletteTitleBackground), image-set(
url('${headerAvif.src}') type('image/avif'),
url('${headerJpg.src}') type('image/jpeg')
)`
),
}),
}) The only workaround I can think of so far is to move the images into the static folder, but that would make the folder too crowded, not exactly a perfect solution. |
Beta Was this translation helpful? Give feedback.
Answered by
nmn
Apr 11, 2025
Replies: 1 comment 1 reply
-
You should only be using values passed in as arguments: const styles = stylex.create({
dynamic: (jpgSource, avifSource) => ({
backgroundImage: stylex.firstThatWorks(
`var(--paletteTitleBackground), url('${jpgSource}')`,
`var(--paletteTitleBackground), image-set(
url('${avifSource}') type('image/avif'),
url('${jpgSource}') type('image/jpeg')
)`
),
}),
}) If this still doesn't work, please open an issue as it should work. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Dattaya
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You should only be using values passed in as arguments:
If this still doesn't work, please open an issue as it should work.