Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

AbirkulovSherali's avatar

"is" attribute in Vuejs

What is "is" attribute used for in Vuejs? I have a vague and incomplete understanding about it.

0 likes
3 replies
tykus's avatar

Rather than using a custom element, you are using an existing HTML element (or Vue's generic component element) and is specifies which of your own components it should be rendered as.

1 like
AbirkulovSherali's avatar

You mean if I don't want to render component this way:

<my-component></my-component>

in a template, I can choose to render this way:

<component is="my-component"></component>

Correct?

1 like
click's avatar
click
Best Answer
Level 35
<div is="my-component"></div>

is equal to

<my-component></my-component>

This is especially useful if you have dynamic components. So you want to load a specific type of component based on a condition. The documentation of vuejs has an example made for it:

And another usecase is to prevent invalid html markup like with table rows: (copied from the vuejs docs)

<table>
  <blog-post-row></blog-post-row>
</table>

The custom component <blog-post-row> will be hoisted out as invalid content, causing errors in the eventual rendered output. Fortunately, the is special attribute offers a workaround:

<table>
  <tr is="blog-post-row"></tr>
</table>
1 like

Please or to participate in this conversation.