New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

vue-boolean

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-boolean

<a h

latest
Source
npmnpm
Version
0.0.11
Version published
Maintainers
1
Created
Source

Vue-Boolean

Downloads Version License

Vue-Boolean it is a renderer for child component

Only for Vue 3

Setup

npm i vue-boolean

Demo

Demo at codesandbox.io

Usage

Composition API


<script setup>
import { VueBoolean } from 'vue-boolean'
import { ref } from 'vue'

const booleanModel = ref(false)
</script>

<template>
  <vue-boolean v-model="booleanModel">
    <button>Press to true</button>
  </vue-boolean>
</template>

Options API


<script>
import { VueBoolean } from 'vue-boolean'

export default {
  components: {
    VueBoolean
  },
  data() {
    return {
      booleanModel: false
    }
  }
}
</script>

<template>
  <vue-boolean v-model="booleanModel">
    <button>Press to true</button>
  </vue-boolean>
</template>

With Nuxt 3

// plugins/vue-boolean.ts

import { defineNuxtPlugin } from 'nuxt/app'
import VueBoolean from 'vue-boolean'
export default defineNuxtPlugin((nuxtApp) => {
    nuxtApp.vueApp.use(VueBoolean)

})


Behaivor

when state set to true, slot class will be set to "checked" with model

props:

@change - fires on state change
:checked - set default state. default - false
v-model - modelled state
event - custom event to change state. "click" by default
className - custom class to add. default - checked

With v-model

<vue-boolean v-model="booleanModel">
    <button>With model</button> 
</vue-boolean>

when clicked it renders to:

<button class="checked">With model</button> 

Without v-model

<vue-boolean>
    <button>without model</button> 
</vue-boolean>

With true by default

<vue-boolean :checked="true">
    <button>with default</button> 
</vue-boolean>

With custom event

<vue-boolean :event="mouseover">
    <button>with event</button> 
</vue-boolean>

With custom class

<vue-boolean class-name="state-checked" v-model="booleanModel">
    <button>With custom class</button> 
</vue-boolean>

renders to

<button class="state-checked">With custom class</button> 

FAQs

Package last updated on 14 Oct 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts