Skip to content

[HELP] Filter out children of a Web Component before rendering. #102

Answered by edoardocavazza
LePichu asked this question in Q&A
Discussion options

You must be logged in to vote

What you are asking is called "slotting". You can use the <slot /> element in the template to render children:

render() {
  return <button>
    <slot />
  </button>;
}

You can read more here.

You can name slots and, maybe, you may be interested to the "extending native elements" section. I strongly advice you to extend the button element instead of wrapping it.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@LePichu
Comment options

@LePichu
Comment options

Answer selected by LePichu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants