Skip to content

useVueToggleInsideTransition (HTML)

Language HTML
biome.json
{
"linter": {
"rules": {
"nursery": {
"useVueToggleInsideTransition": "error"
}
}
}
}

Require the element inside a Vue <Transition> to be shown and hidden with v-if or v-show.

A <Transition> plays its animation when the element inside it is added, removed, shown, or hidden. An element that is always shown never changes, so the animation never plays.

The rule checks the first element inside each <Transition>. That element is accepted when one of the following is true:

  • it has a v-if or v-show directive;
  • it has a key bound with :key or v-bind:key, because Vue replaces the element when the key changes;
  • it is a component, a <component>, a <slot>, or an element with an is attribute, because the rule can’t see what they render;
  • the <Transition> has the appear attribute, which plays the animation when the element is first shown. :appear="false" doesn’t count.
<template>
<Transition>
<div>Content</div>
</Transition>
</template>
code-block.vue:3:5 lint/nursery/useVueToggleInsideTransition ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ This element inside <Transition> is never shown or hidden.

1 │ <template>
2 │ <Transition>
> 3 │ <div>Content</div>
│ ^^^^^
4 │ </Transition>
5 │ </template>

ℹ A transition only plays when the element inside it appears or disappears. This element is always present, so the transition never plays.

ℹ Add v-if or v-show to the element, or bind a :key that changes when the content does.

ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

<template>
<Transition>
<div v-if="visible">Content</div>
</Transition>
<Transition>
<div v-show="visible">Content</div>
</Transition>
<Transition>
<div :key="step">Content</div>
</Transition>
<Transition>
<MyComponent />
</Transition>
<Transition appear>
<div>Content</div>
</Transition>
</template>