UNPKG

pkg-components

Version:
89 lines (77 loc) 1.51 kB
.container { display: flex; align-items: center; } .switch { position: relative; display: inline-block; height: fit-content; display: flex; align-items: center; } .switch input { opacity: 0; width: 0; height: 0; } .track { position: relative; width: 56px; height: 28px; border-radius: 999px; cursor: pointer; display: flex; align-items: center; justify-content: space-between; padding: 0 6px; box-shadow: 0 0 0 6px rgba(0, 0, 0, 0.05); transition: background-color 350ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 250ms ease; } .thumb { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; background-color: #fff; border-radius: 50%; transition: transform 450ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 250ms ease; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25); } input:checked + .track .thumb { transform: translateX(28px); } .icon { display: flex; align-items: center; justify-content: center; color: #fff; opacity: 0.6; transform: scale(0.85); transition: opacity 300ms ease, transform 300ms ease; } .left { margin-right: auto; } .right { margin-left: auto; } input:not(:checked) + .track .left { opacity: 1; transform: scale(1); } input:checked + .track .right { opacity: 1; transform: scale(1); } .label { margin-left: 12px; color: #9e9e9e; transition: color 250ms ease; }