Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need enabled prop for dynamically enable/disable tippy #274

Open
lukas-pierce opened this issue Dec 28, 2022 · 6 comments
Open

Need enabled prop for dynamically enable/disable tippy #274

lukas-pierce opened this issue Dec 28, 2022 · 6 comments

Comments

@lukas-pierce
Copy link

Heed simple enabled boolean prop:

<template>
  <!--Switcher-->
  <label><input type="checkbox" v-model="tippyEnabled"> Enable tippy</label>

  <!--button with optional tippy-->
  <button v-tippy="{content: 'Some content', enabled: tippyEnabled}">Hover me</button>
</template>

<script setup>
const tippyEnabled = ref(false)
</script>

Now for this approach I need use composition API with useTippy(), It looks bulky:

<template>
  <!--Switcher-->
  <label><input type="checkbox" v-model="tippyEnabled"> Enable tippy</label>

  <!--button with optional tippy-->
  <button ref="button">Hover me</button>
</template>

<script setup>
import { useTippy } from 'vue-tippy'

const tippyEnabled = ref(false)
const button = ref(null)

// need wrap this hook for nuxt usage
onMounted(() => {
  if (button.value) {

    // create Tippy instance
    const { enable, disable } = useTippy(button.value, {
      content: 'Some content',
    })

    watchEffect(() => {
      tippyEnabled.value ? enable() : disable()
    })
  }
})
</script>
@lukas-pierce lukas-pierce changed the title Need enabled prop for dynamically enable disable tippy Need enabled prop for dynamically enable/disable tippy Dec 28, 2022
@KABBOUCHI
Copy link
Owner

u can use onShow to disable the tooltip

  <button v-tippy="{ content: 'Some content', onShow: () => true }">
    Hover me
  </button>

https://codesandbox.io/p/sandbox/practical-noyce-nug0jl

@a-ruban
Copy link

a-ruban commented Mar 6, 2023

@KABBOUCHI also vote for "enabled" prop, it's just more explicit and obvious

@JackHamer09
Copy link

+1

@yulafezmesi
Copy link

+1 for enabled prop.

@daniilgri
Copy link

+1

1 similar comment
@FredrikAnkarang
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants