Dice - Web Component
✓ Published0🌍 Public
Aangusgrant
Last edited Feb 28, 2023
Created on Feb 28, 2023
This example demonstrates a custom web component that renders a dice-rolling button and an accessible output area. The component, defined as `roll-dice`, uses the `HTMLElement` class and the `customElements.define` API to encapsulate its template, which includes a button with customizable text and a `div` with an `aria-live` attribute for screen-reader announcements. The component dynamically replaces its original content with this structure upon instantiation, supporting multiple instances on a page. No dice-rolling logic is implemented; only the component’s markup and lifecycle setup are shown.
AI-generated description