index.html 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. <!DOCTYPE html>
  2. <head>
  3. <title>Alpine Clipboard</title>
  4. <script src="//unpkg.com/alpinejs" defer></script>
  5. </head>
  6. <body>
  7. <div x-data="{ input: '' }">
  8. <input x-model="input">
  9. <button type="button" @click="await $clipboard(input)">Copy to Clipboard</button>
  10. </div>
  11. <div x-data="{}">
  12. <button type="button" @click="$clipboard(() => 'Testing')">Copy 'Testing' to Clipboard</button>
  13. </div>
  14. <div x-data="{ items: ['foo', 'bar'] }">
  15. <template x-for="item in items">
  16. <p x-text="item"></p>
  17. </template>
  18. <button type="button" @click="$clipboard(items)">Copy the JSON representation of `items` to your clipboard</button>
  19. </div>
  20. <div x-data="{ text: 'boo' }">
  21. <button x-clipboard="text">This uses clipboard directive to copy the text "boo" to your clipboard.</button>
  22. <button x-clipboard.raw="Here is some raw text to copy to the clipboard.">
  23. This will let you copy any raw text in the directive.
  24. </button>
  25. </div>
  26. <script src="../dist/alpine-clipboard.js"></script>
  27. </body>