Skip to content

Commit

Permalink
added tips to README.md
Browse files Browse the repository at this point in the history
Signed-off-by: StoneyDSP <nathanjhood@googlemail.com>
  • Loading branch information
nathanjhood committed Oct 17, 2024
1 parent ffd3679 commit bf3a648
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,37 @@ const customButtonB = CustomButton({ type: 'submit', children: customButton });

---

### adding styles

```ts
type CustomButtonProps = {
type: 'submit' | 'reset' | 'button';
children?: Node;
className?: string;
};

const CustomButton = (props: CustomButtonProps): HTMLButtonElement => {
class CustomButton extends HTMLButtonElement {
constructor() {
super();
this.type = props.type;
if (props.children) this.appendChild(props.children);
if (props.className) this.className = props.className;
}
}
customElements.define('custom-button', CustomButton);
return document.createElement<'button'>('button');
};

const tailwindButton = CustomButton({
type: 'submit',
className: 'flex align-left text-white bg-red-500',
});

```

---

## Further Reading

- [eiwenebergeffect @ Medium: Hello Web Components](https://eisenbergeffect.medium.com/hello-web-components-795ed1bd108e)
Expand Down

0 comments on commit bf3a648

Please sign in to comment.