Per this issue with the W3C html spec, using nested sections with multiple h1's is discouraged because no browsers implement the outline algorithm needed to make them work semantically.
However, if I have a custom element that needs to use a heading element, I haven't been able to find the recommended way for it to figure out what the heading level is where it's being upgraded/inserted into (so the element can determine which h1-h6 to use)
I found this article detailing some workarounds for the issue (that applies to components more generally), as well as one specific to React, but they all seemed a little clunky.
It seemed like this could be a common enough problem for there to be a recommended pattern on how to handle it (better than just passing/managing an attribute for it), but I don't know what that would be (I'm fairly new to web components)
<main>
content, then you can pretty much count on using, say, an<h2>
for its heading. I’m sure you are using it for something more complex, which causes your problem, I’m just saying that on most websites you’d avoid this by designing a proper document structure. – Dauphine