1
0
pines/elements/switch-examples/example-01.html
2023-06-14 12:34:54 -04:00

20 lines
904 B
HTML

<div x-data="{ switchOn: false }" class="flex items-center justify-center space-x-2">
<input id="thisId" type="checkbox" name="switch" class="hidden" :checked="switchOn">
<button
x-ref="switchButton"
type="button"
@click="switchOn = ! switchOn"
:class="switchOn ? 'bg-neutral-900' : 'bg-neutral-200'"
class="relative inline-flex h-4 py-0.5 ml-4 rounded-full focus:outline-none w-6"
x-cloak>
<span :class="switchOn ? 'translate-x-[10px]' : 'translate-x-0.5'" class="w-3 h-3 duration-200 ease-in-out bg-white rounded-full shadow-md"></span>
</button>
<label @click="$refs.switchButton.click(); $refs.switchButton.focus()" :id="$id('switch')"
:class="{ 'text-neutral-900': switchOn, 'text-gray-400': ! switchOn }"
class="text-xs font-medium select-none"
x-cloak>
Enable Feature
</label>
</div>