Closed JayGeorge closed 11 months ago
The svg tag has title
and desc
parameters you can use. It was added in 3.3.66 https://github.com/statamic/cms/pull/7348 But were never documented, sorry we'll get on that.
{{ svg src="logo" title="something" desc="something" }}
But I'm now seeing that you also want title and desc to have ids. And probably aria-labelledby="uniqueTitleID uniqueDescID"
on the svg itself?
The svg tag has title and desc parameters you can use.
Ah great, that does help a lot!
But I'm now seeing that you also want title and desc to have ids. And probably aria-labelledby="uniqueTitleID uniqueDescID" on the svg itself?
Actually, reading the CSS-Tricks article more carefully, those extra things were something that was needed a while back to get around browser bugs, but it looks like Chrome and Firefox have fixed those bugs now.
So I think that's solved!
It would be great if we could pass variables to an SVG tag, like this:
{{ svg src='logo' some_var='1' }}
Then inside the SVG:
<title id="logo-{{ some_var }}">
Background/Context
Making an SVG accessible involves adding unique Title and Description IDs for screen readers, like this:
(source)
This is easy but if you try to use the same SVG more than once on a page (quite often happens when using SVG "icons"), if you run your site through a validator then you'll get an error like this:
Duplicate ID validation error
, since every SVG title and description needs to be unique.It would be handy to be able to do something like this in order to mitigate this:
{{ svg src='logo' index='1' }}
Then inside the SVG: