sveltejs / sveltejs/kit

`<picture />` elements generated by `@sveltejs/enhanced-img` cannot be styled

Open
#11,017 10 comments 19 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

pkg:enhanced-img
Dominant language
JavaScript
Stars
20.8k
Forks
2.3k
Avg merge
1d 16h
Merged PRs (30d)
156

Description

Describe the problem

Classes/styles applied to <enhanced:img /> elements are applied to the contained <img /> element, not the outer container. This makes grid/flex layouts hard to manage without a wrapper element.

<enhanced:img class="grid-item" />

becomes

<picture>
  <img class="grid-item" />
</picture>
Describe the proposed solution

The <picture /> element could be marked as display: contents, or maybe classes/styles could be applied to the <picture />.

The example above could become either

<picture style="display:contents">
  <img class="grid-item" />
</picture>

or

<picture class="grid-item">
  <img />
</picture>
Alternatives considered

As a workaround, you can wrap a <div /> around each <enhanced:img /> with your grid/flex logic applied to it, but this feels wrong when <picture /> is already wrapping your images.

Importance

would make my life easier

Additional Information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start from the @sveltejs/enhanced-img transformation that handles <enhanced:img /> attributes and inspect how classes and styles are transferred into the generated and elements. Compare the proposed output options and confirm the chosen behavior with the existing generated markup; done means users can style the outer picture element for grid or flex layouts without an extra wrapper.

Written by the indexing model from the issue text.

Assessment

Tech stack
html, javascript
Domain
frontend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
64/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.