1
0
pines/elements/switch-examples/example-01.html

20 lines
904 B
HTML
Raw Permalink Normal View History

<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'"
2023-06-14 09:34:54 -07:00
class="relative inline-flex h-4 py-0.5 ml-4 rounded-full focus:outline-none w-6"
x-cloak>
2023-06-14 09:34:54 -07:00
<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>