Closed samuelhulla closed 3 months ago
I'm not sure this is a bug in Astro. When you use an SVG via an <img>
tag, the nested <style>
will no longer work, it's the default browser behaviour. If you want the <style>
to work, you need to inline it, either via your .astro
file trick, or import with:
---
import example from '../assets/example.svg?raw'
---
<Fragment set:html={example} />
The Image component uses img
to embed the SVG, which cannot use fonts.
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
When using a
.svg
file with a<style>
tag, like the one in the example withfont-family
definition, astro seems to strap it clean of these tags and just defaults to whatever my default font is.however, my font-family does not apply
As you can see, my style does not get respected in the svg
What's the expected result?
I would expect my fonts load properly when using the
<Image>
fromastro:assets
<style is:global>
and mytailwind.config.mjs
and i can confirm that the font linking works properly, because, when using it in a<p>
tag it works as expectedWhat leads me to believe this is due to astro doing some image processing is because if I change my
.svg
to a.astro
file and just use it as a standalone component that happens to return an svg it does workLink to Minimal Reproducible Example
https://stackblitz.com/edit/github-nhfu4n?file=src%2Fpages%2Findex.astro
Participation