remarkjs / react-markdown

Markdown component for React
https://remarkjs.github.io/react-markdown/
MIT License
13.27k stars 876 forks source link

Support passing 'id' (or any other arbitrary 'div' tags) #792

Closed CHE1RON closed 1 year ago

CHE1RON commented 1 year ago

Initial checklist

Problem

When rendering Markdown, it wraps all content inside a <div>, but does not provide any means to pass arbitrary or even the most basic props to this element (className being the only one).

I stumbled across https://github.com/remarkjs/react-markdown/issues/242, which I think is about exactly this, but was discarded as 'add props to components being rendered inside this div tag' - however, the issue still stands 😁

Solution

I'd be happy to open a PR for at least id to be an allowed property - think of aria-labelledby referencing this without having to wrap it in yet another div!

Alternatives

It might be solved by having div props being passed as single argument 🤔

wooorm commented 1 year ago

Hey!

We don’t generate a div normally. Only with className. If you want a div with an id or whatever else, write one:

<div id="x">
  <Markdown><Markdown>
</div>

This seems more like #781. Either we can remove className, and this div, or we can pass all other properties through to a div. Leave a comment there if you feel for one or the other!

github-actions[bot] commented 1 year ago

Hi! This was closed. Team: If this was fixed, please add phase/solved. Otherwise, please add one of the no/* labels.