Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import { Component, Prop, State } from '@stencil/core';
@Component({
tag: 'my-custom-button',
styleUrl: 'my-custom-button.scss'
})
export class MyCustomButtonComponent {
@Prop() myCustomAttribute: string;
@State() checked: boolean;
toggleChecked(event: UIEvent) {
this.checked = !this.checked;
}
render() {
return (
<div onClick={(event: UIEvent) => this.toggleChecked(event)}>
<span className={(this.checked && "checked")}></span>
{this.myCustomAttribute}
</div>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment