Skip to main content

Component

Callable


  • Creates a new web component class.

    Specify props and events using the metadata parameter.

    @example
    class MyComponent extends Component("my-component", {
    myProp: prop<string>("Hello, world!"),
    onMyEvent: event(),
    }) {
    render() {
    return (
    <>
    <h1>{this.props.myProp}</h1>
    <button onclick={() => this.events.onMyEvent()}>Click me</button>
    </>
    );
    },
    }

    customElements.define("my-component", MyComponent);