Skip to content

booleanProp NPM Version

Stability: experimental ⚠️ Experimental feature, use at your risk

Convert <Comp checked /> to <Comp :checked="true" />.

Convert <Comp !checked /> to <Comp :checked="false" />.

FeaturesSupported
Vue 3
Nuxt 3
Vue 2
Volar Plugin

Options

ts
interface Options {
  /**
   * @default '!'
   */
  negativePrefix?: string
}

Usage

vue
<script setup>
import 
Comp
from './Comp.vue'
</script> <template> <
Comp
checked
!
enabled
/>
</template>
vue
<script setup lang="ts">
// Comp.vue
defineProps
<{
checked
: true
enabled
: false
}>() </script>

Volar Configuration

jsonc
// tsconfig.json
{
  "vueCompilerOptions": {
    "target": 3,
    "plugins": [
      "@vue-macros/volar/boolean-prop",
      // ...more feature
    ],
  },
}

Contributors

The avatar of contributor named as Kevin Deng Kevin Deng

Changelog