UNPKG

ui-humix-lib

Version:

A simple package for implementinghumix design components in react-based or node.js based projects.

20 lines (18 loc) 904 B
<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>