Skip to content

KClipboardProvider

KClipboardProvider provides clipboard functionality to components.

html
<template>
  <KInput :model-value="dataToCopy" @input="newValue => dataToCopy = newValue" type="text" />
  <KClipboardProvider v-slot="{ copyToClipboard }">
    <KButton @click="() => { if (copyToClipboard(dataToCopy)) alert(`Copied '${dataToCopy}'`) }">
      Copy to Clipboard
    </KButton>
  </KClipboardProvider>
</template>

<script setup lang="ts">
import { ref } from 'vue'

const dataToCopy = ref('Copy this to the clipboard')

const alert = (msg: string): void => {
  window.alert(msg)
}
</script>

Slots

  • default - content to toggle.

Slot Props

PropsTypeDescription
copyToClipboardFunctionCopy to clipboard; @returns {Boolean}

Released under the Apache-2.0 License.