Custom HTML elements
Overview (reference)
Section titled Overview (reference)You can always create your own custom HTML elements and then use them alongside built-in ones, e.g.:
You can read more about this in this person’s blog post.
Basic usage
Section titled Basic usageHere’s a simple component that extends HTMLElement
:
Then, to use the new astro-greet
element, you could do something like this:
How querySelector
works
Section titled How querySelector worksSuppose you have this:
…each AstroGreet
can find its own local button with this.querySelector("#test")
. However, in the resulting HTML, both buttons will have exactly the same ID.