<div x-data="selectBox()">
<button x-on:click="selectAll">select all</button>
<button x-on:click="unselectAll">unselect all</button>
<template x-for="name in allNames">
<input type="checkbox" :value="name" x-model="checkedNames">
</template>
<span x-text="JSON.stringify(checkedNames)"></span>
</div>
<script>
function selectBox() {
return {
checkedNames: [],
allNames: ['bike', 'car', 'boat'],
selectAll() { this.checkedNames = this.allNames },
unselectAll() { this.checkedNames = []},
}
}
</script>