I stumbled upon a package that has no js or html, only css and it defines a custom element which can be used in html:
<status-indicator active pulse></status-indicator>
The only declaration I see for this is in the css file:
status-indicator {
display: inline-block;
border-radius: 50%;
cursor: pointer;
width: var(--status-indicator-size);
height: var(--status-indicator-size);
background-color: var(--status-indicator-color);
}
This is the package: https://www.npmjs.com/package/status-indicator
For the sake of learning - could anyone explain how and why this works or where should I refer to read about it?
html&CSSuse with className and here same is applied but with a custom tagcustomElements.get("status-indicator")and you will getundefined.<status-indicator>isn't a Custom Element at all (yet). But it is perfectly fine to assign CSS to these elements; that is all the author does.