[@astrojs/image] Ability to add a class to <picture> element #5476
Labels
- P2: nice to have
Not breaking anything but nice to have (priority)
pkg: image
Related to the `@astrojs/image` package (scope)
What version of
astro
are you using?1.6.11
Are you using an SSR adapter? If so, which one?
None
What package manager are you using?
npm
What operating system are you using?
Mac
Describe the Bug
Problem
Can't lay out
<Picture>
inside a CSS grid containerReason
Before @astrojs/image 0.11.0, adding a
class
prop to<Picture>
, the class would be put on the internal HTML<picture>
element. If I wanted to style the<picture>
element I could refer to the class, and if I wanted to style the underlying<img>
element I could refer to.myClass img
. This allowed me to put most of the styles on the<img>
element, but addgrid-area
/grid-row
/grid-column
CSS properties on the<picture>
element. Putting those CSS properties on the<img>
element don't do anything.Proposed solution
Keep the
class
prop on the<img>
, but add apictureClass
prop that puts the class name on the<picture>
element.Possible workaround
Set
picture { display: contents; }
as a global style in my project. I can't find this suggested anywhere on the internet, and I hesitate to do this without exploring if there are any downsides to this - does it break how<picture>
natively works or change the accessibility semantics in a negative way?Link to Minimal Reproducible Example
N/A
Participation
The text was updated successfully, but these errors were encountered: