Skip to content

should not use div wrapper #115

Open

Description

@willin

When i use the component in markdown or mdx, the generated codes a bit like:

<p>
    <div class="rc-image" style="width: 200px;">
        <img class="rc-image-img" src="https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png" />
    </div>
</p>

However, the P element represents a paragraph. It cannot contain block-level elements (including P itself).

Activity

  1. rickyzhangca commented on Mar 21, 2022

    @rickyzhangca

    another downside of the current wrapper handling is that the classnames are trapped on the <img> instead of transferred to the wrapper, so the styling is difficult - especially if you use tailwindcss, you'll need to add another wrapper yourself

    image

  2. afc163 commented on Aug 8, 2022

    @afc163
    Member

    How about adding a component="div" for customization?

  3. AoDev commented on Aug 28, 2025

    @AoDev

    Old issue. Started to use rc-image. Got the same problem. It's problematic for layouts. I'm not digging into the code. From a naive point of view, I don't see a reason for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions