Tailwind Toggle

https://codepen.io/junchow/pen/VweLgOb?editors=1000

切换

toggle
<div class="relative inline-block w-10 mr-2 align-middle select-none transition duration-200 ease-in">
  <input type="checkbox" id="toggle" class="absolute block w-6 h-6 border-4 rounded-full bg-white cursor-pointer appearance-none toggle-checkbox">
  <label for="toggle" class="block h-6 rounded-full bg-gray-300 cursor-pointer overflow-hidden toggle-label"></label>
</div>

切换效果CSS实现

.toggle-checkbox:checked{
  @applay:right-0 border-green-400;
  right:0;
  border-color:#68D391;
}
.toggle-checkbox:checked + .toggle-label{
  @apply:bg-green-400;
  background-color:#68D391;
}

切换

toggle
<link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet">
<link href="https://cdn.bootcdn.net/ajax/libs/font-awesome/5.13.0/css/all.min.css" rel="stylesheet">

<div class="container mx-auto my-12 p-12 bg-gray-100">
  <div class="inline-flex rounded-full border-1 border-gray-300 bg-gray-200 shadow-md leading-none text-sm">
    <button class="inline-flex items-center px-4 py-2 bg-white rounded-full text-blue-400 transition-colors duration-300 ease-in focus:outline-none focus:text-blue-400 hover:text-blue-400">
      <i class="fa fa-th mr-2"></i>
      <span>表格</span>
    </button>
    <button class="inline-flex items-center px-4 py-2 rounded-r-full text-gray-500 transition-colors duration-300 ease-in focus:outline-none focus:text-blue-400 hover:text-blue-400">
      <i class="fa fa-list mr-2"></i>
      <span>列表</span>
    </button>
  </div>
</div>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值