bulma-switch-control
Version:
Switch controls for Bulma CSS Framework
597 lines (460 loc) • 15.3 kB
CSS
/* Bulma Utilities */
.switch {
-webkit-touch-callout: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
/* Box-shadow */
.switch {
cursor: pointer;
display: inline-flex;
align-items: center;
position: relative;
margin-right: 0.5em;
}
.switch + .switch:last-child {
margin-right: 0;
}
.switch input[type=checkbox] {
position: absolute;
left: 0;
opacity: 0;
outline: none;
z-index: -1;
}
.switch input[type=checkbox] + .check {
display: flex;
align-items: center;
flex-shrink: 0;
width: 2.75em;
height: 1.575em;
padding: 0.2em;
background: #b5b5b5;
border-radius: 4px;
transition: background 150ms ease-out, box-shadow 150ms ease-out;
}
.switch input[type=checkbox] + .check.is-white-passive, .switch input[type=checkbox] + .check:hover {
background: white;
}
.switch input[type=checkbox] + .check.input[type=checkbox] + .switch input[type=checkbox] + .check.check {
background: 'pink';
}
.switch input[type=checkbox] + .check.is-black-passive, .switch input[type=checkbox] + .check:hover {
background: #0a0a0a;
}
.switch input[type=checkbox] + .check.input[type=checkbox] + .switch input[type=checkbox] + .check.check {
background: 'pink';
}
.switch input[type=checkbox] + .check.is-light-passive, .switch input[type=checkbox] + .check:hover {
background: whitesmoke;
}
.switch input[type=checkbox] + .check.input[type=checkbox] + .switch input[type=checkbox] + .check.check {
background: 'pink';
}
.switch input[type=checkbox] + .check.is-dark-passive, .switch input[type=checkbox] + .check:hover {
background: #363636;
}
.switch input[type=checkbox] + .check.input[type=checkbox] + .switch input[type=checkbox] + .check.check {
background: 'pink';
}
.switch input[type=checkbox] + .check.is-primary-passive, .switch input[type=checkbox] + .check:hover {
background: #00d1b2;
}
.switch input[type=checkbox] + .check.input[type=checkbox] + .switch input[type=checkbox] + .check.check {
background: 'pink';
}
.switch input[type=checkbox] + .check.is-link-passive, .switch input[type=checkbox] + .check:hover {
background: #485fc7;
}
.switch input[type=checkbox] + .check.input[type=checkbox] + .switch input[type=checkbox] + .check.check {
background: 'pink';
}
.switch input[type=checkbox] + .check.is-info-passive, .switch input[type=checkbox] + .check:hover {
background: #3e8ed0;
}
.switch input[type=checkbox] + .check.input[type=checkbox] + .switch input[type=checkbox] + .check.check {
background: 'pink';
}
.switch input[type=checkbox] + .check.is-success-passive, .switch input[type=checkbox] + .check:hover {
background: #48c78e;
}
.switch input[type=checkbox] + .check.input[type=checkbox] + .switch input[type=checkbox] + .check.check {
background: 'pink';
}
.switch input[type=checkbox] + .check.is-warning-passive, .switch input[type=checkbox] + .check:hover {
background: #ffe08a;
}
.switch input[type=checkbox] + .check.input[type=checkbox] + .switch input[type=checkbox] + .check.check {
background: 'pink';
}
.switch input[type=checkbox] + .check.is-danger-passive, .switch input[type=checkbox] + .check:hover {
background: #f14668;
}
.switch input[type=checkbox] + .check.input[type=checkbox] + .switch input[type=checkbox] + .check.check {
background: 'pink';
}
.switch input[type=checkbox] + .check:before {
content: "";
display: block;
border-radius: 4px;
width: 1.175em;
height: 1.175em;
background: whitesmoke;
transition: transform 150ms ease-out;
will-change: transform;
transform-origin: left;
}
.switch input[type=checkbox] + .check.is-elastic:before {
transform: scaleX(1.5);
border-radius: 4px;
}
.switch input[type=checkbox]:checked + .check {
background: #00d1b2;
}
.switch input[type=checkbox]:checked + .check.is-white {
background: white;
}
.switch input[type=checkbox]:checked + .check.is-black {
background: #0a0a0a;
}
.switch input[type=checkbox]:checked + .check.is-light {
background: whitesmoke;
}
.switch input[type=checkbox]:checked + .check.is-dark {
background: #363636;
}
.switch input[type=checkbox]:checked + .check.is-primary {
background: #00d1b2;
}
.switch input[type=checkbox]:checked + .check.is-link {
background: #485fc7;
}
.switch input[type=checkbox]:checked + .check.is-info {
background: #3e8ed0;
}
.switch input[type=checkbox]:checked + .check.is-success {
background: #48c78e;
}
.switch input[type=checkbox]:checked + .check.is-warning {
background: #ffe08a;
}
.switch input[type=checkbox]:checked + .check.is-danger {
background: #f14668;
}
.switch input[type=checkbox]:checked + .check:before {
transform: translate3d(100%, 0, 0);
}
.switch input[type=checkbox]:checked + .check.is-elastic:before {
transform: translate3d(50%, 0, 0) scaleX(1.5);
}
.switch input[type=checkbox]:focus, .switch input[type=checkbox]:active {
outline: none;
}
.switch .control-label {
padding-left: 0.5em;
}
.switch:hover input[type=checkbox] + .check {
background: rgba(181, 181, 181, 0.9);
}
.switch:hover input[type=checkbox] + .check.is-white-passive {
background: rgba(255, 255, 255, 0.9);
}
.switch:hover input[type=checkbox] + .check.is-black-passive {
background: rgba(10, 10, 10, 0.9);
}
.switch:hover input[type=checkbox] + .check.is-light-passive {
background: rgba(245, 245, 245, 0.9);
}
.switch:hover input[type=checkbox] + .check.is-dark-passive {
background: rgba(54, 54, 54, 0.9);
}
.switch:hover input[type=checkbox] + .check.is-primary-passive {
background: rgba(0, 209, 178, 0.9);
}
.switch:hover input[type=checkbox] + .check.is-link-passive {
background: rgba(72, 95, 199, 0.9);
}
.switch:hover input[type=checkbox] + .check.is-info-passive {
background: rgba(62, 142, 208, 0.9);
}
.switch:hover input[type=checkbox] + .check.is-success-passive {
background: rgba(72, 199, 142, 0.9);
}
.switch:hover input[type=checkbox] + .check.is-warning-passive {
background: rgba(255, 224, 138, 0.9);
}
.switch:hover input[type=checkbox] + .check.is-danger-passive {
background: rgba(241, 70, 104, 0.9);
}
.switch:hover input[type=checkbox]:checked + .check {
background: rgba(0, 209, 178, 0.9);
}
.switch:hover input[type=checkbox]:checked + .check.is-white {
background: rgba(255, 255, 255, 0.9);
}
.switch:hover input[type=checkbox]:checked + .check.is-black {
background: rgba(10, 10, 10, 0.9);
}
.switch:hover input[type=checkbox]:checked + .check.is-light {
background: rgba(245, 245, 245, 0.9);
}
.switch:hover input[type=checkbox]:checked + .check.is-dark {
background: rgba(54, 54, 54, 0.9);
}
.switch:hover input[type=checkbox]:checked + .check.is-primary {
background: rgba(0, 209, 178, 0.9);
}
.switch:hover input[type=checkbox]:checked + .check.is-link {
background: rgba(72, 95, 199, 0.9);
}
.switch:hover input[type=checkbox]:checked + .check.is-info {
background: rgba(62, 142, 208, 0.9);
}
.switch:hover input[type=checkbox]:checked + .check.is-success {
background: rgba(72, 199, 142, 0.9);
}
.switch:hover input[type=checkbox]:checked + .check.is-warning {
background: rgba(255, 224, 138, 0.9);
}
.switch:hover input[type=checkbox]:checked + .check.is-danger {
background: rgba(241, 70, 104, 0.9);
}
.switch.is-rounded input[type=checkbox] + .check {
border-radius: 9999px;
}
.switch.is-rounded input[type=checkbox] + .check:before {
border-radius: 9999px;
}
.switch.is-rounded input[type=checkbox].is-elastic:before {
transform: scaleX(1.5);
border-radius: 9999px;
}
.switch.is-outlined input[type=checkbox] + .check {
background: transparent;
border: 0.1rem solid #b5b5b5;
padding: 0.1em;
}
.switch.is-outlined input[type=checkbox] + .check.is-white-passive {
border: 0.1rem solid rgba(255, 255, 255, 0.9);
}
.switch.is-outlined input[type=checkbox] + .check.is-white-passive:before {
background: white;
}
.switch.is-outlined input[type=checkbox] + .check.is-white-passive:hover {
border-color: rgba(255, 255, 255, 0.9);
}
.switch.is-outlined input[type=checkbox] + .check.is-black-passive {
border: 0.1rem solid rgba(10, 10, 10, 0.9);
}
.switch.is-outlined input[type=checkbox] + .check.is-black-passive:before {
background: #0a0a0a;
}
.switch.is-outlined input[type=checkbox] + .check.is-black-passive:hover {
border-color: rgba(10, 10, 10, 0.9);
}
.switch.is-outlined input[type=checkbox] + .check.is-light-passive {
border: 0.1rem solid rgba(245, 245, 245, 0.9);
}
.switch.is-outlined input[type=checkbox] + .check.is-light-passive:before {
background: whitesmoke;
}
.switch.is-outlined input[type=checkbox] + .check.is-light-passive:hover {
border-color: rgba(245, 245, 245, 0.9);
}
.switch.is-outlined input[type=checkbox] + .check.is-dark-passive {
border: 0.1rem solid rgba(54, 54, 54, 0.9);
}
.switch.is-outlined input[type=checkbox] + .check.is-dark-passive:before {
background: #363636;
}
.switch.is-outlined input[type=checkbox] + .check.is-dark-passive:hover {
border-color: rgba(54, 54, 54, 0.9);
}
.switch.is-outlined input[type=checkbox] + .check.is-primary-passive {
border: 0.1rem solid rgba(0, 209, 178, 0.9);
}
.switch.is-outlined input[type=checkbox] + .check.is-primary-passive:before {
background: #00d1b2;
}
.switch.is-outlined input[type=checkbox] + .check.is-primary-passive:hover {
border-color: rgba(0, 209, 178, 0.9);
}
.switch.is-outlined input[type=checkbox] + .check.is-link-passive {
border: 0.1rem solid rgba(72, 95, 199, 0.9);
}
.switch.is-outlined input[type=checkbox] + .check.is-link-passive:before {
background: #485fc7;
}
.switch.is-outlined input[type=checkbox] + .check.is-link-passive:hover {
border-color: rgba(72, 95, 199, 0.9);
}
.switch.is-outlined input[type=checkbox] + .check.is-info-passive {
border: 0.1rem solid rgba(62, 142, 208, 0.9);
}
.switch.is-outlined input[type=checkbox] + .check.is-info-passive:before {
background: #3e8ed0;
}
.switch.is-outlined input[type=checkbox] + .check.is-info-passive:hover {
border-color: rgba(62, 142, 208, 0.9);
}
.switch.is-outlined input[type=checkbox] + .check.is-success-passive {
border: 0.1rem solid rgba(72, 199, 142, 0.9);
}
.switch.is-outlined input[type=checkbox] + .check.is-success-passive:before {
background: #48c78e;
}
.switch.is-outlined input[type=checkbox] + .check.is-success-passive:hover {
border-color: rgba(72, 199, 142, 0.9);
}
.switch.is-outlined input[type=checkbox] + .check.is-warning-passive {
border: 0.1rem solid rgba(255, 224, 138, 0.9);
}
.switch.is-outlined input[type=checkbox] + .check.is-warning-passive:before {
background: #ffe08a;
}
.switch.is-outlined input[type=checkbox] + .check.is-warning-passive:hover {
border-color: rgba(255, 224, 138, 0.9);
}
.switch.is-outlined input[type=checkbox] + .check.is-danger-passive {
border: 0.1rem solid rgba(241, 70, 104, 0.9);
}
.switch.is-outlined input[type=checkbox] + .check.is-danger-passive:before {
background: #f14668;
}
.switch.is-outlined input[type=checkbox] + .check.is-danger-passive:hover {
border-color: rgba(241, 70, 104, 0.9);
}
.switch.is-outlined input[type=checkbox] + .check:before {
background: #b5b5b5;
}
.switch.is-outlined input[type=checkbox]:checked + .check {
border-color: #00d1b2;
}
.switch.is-outlined input[type=checkbox]:checked + .check.is-white {
background: transparent;
border-color: white;
}
.switch.is-outlined input[type=checkbox]:checked + .check.is-white:before {
background: white;
}
.switch.is-outlined input[type=checkbox]:checked + .check.is-black {
background: transparent;
border-color: #0a0a0a;
}
.switch.is-outlined input[type=checkbox]:checked + .check.is-black:before {
background: #0a0a0a;
}
.switch.is-outlined input[type=checkbox]:checked + .check.is-light {
background: transparent;
border-color: whitesmoke;
}
.switch.is-outlined input[type=checkbox]:checked + .check.is-light:before {
background: whitesmoke;
}
.switch.is-outlined input[type=checkbox]:checked + .check.is-dark {
background: transparent;
border-color: #363636;
}
.switch.is-outlined input[type=checkbox]:checked + .check.is-dark:before {
background: #363636;
}
.switch.is-outlined input[type=checkbox]:checked + .check.is-primary {
background: transparent;
border-color: #00d1b2;
}
.switch.is-outlined input[type=checkbox]:checked + .check.is-primary:before {
background: #00d1b2;
}
.switch.is-outlined input[type=checkbox]:checked + .check.is-link {
background: transparent;
border-color: #485fc7;
}
.switch.is-outlined input[type=checkbox]:checked + .check.is-link:before {
background: #485fc7;
}
.switch.is-outlined input[type=checkbox]:checked + .check.is-info {
background: transparent;
border-color: #3e8ed0;
}
.switch.is-outlined input[type=checkbox]:checked + .check.is-info:before {
background: #3e8ed0;
}
.switch.is-outlined input[type=checkbox]:checked + .check.is-success {
background: transparent;
border-color: #48c78e;
}
.switch.is-outlined input[type=checkbox]:checked + .check.is-success:before {
background: #48c78e;
}
.switch.is-outlined input[type=checkbox]:checked + .check.is-warning {
background: transparent;
border-color: #ffe08a;
}
.switch.is-outlined input[type=checkbox]:checked + .check.is-warning:before {
background: #ffe08a;
}
.switch.is-outlined input[type=checkbox]:checked + .check.is-danger {
background: transparent;
border-color: #f14668;
}
.switch.is-outlined input[type=checkbox]:checked + .check.is-danger:before {
background: #f14668;
}
.switch.is-outlined input[type=checkbox]:checked + .check:before {
background: #00d1b2;
}
.switch.is-outlined:hover input[type=checkbox] + .check {
background: transparent;
border-color: rgba(181, 181, 181, 0.9);
}
.switch.is-outlined:hover input[type=checkbox]:checked + .check {
background: transparent;
border-color: rgba(0, 209, 178, 0.9);
}
.switch.is-outlined:hover input[type=checkbox]:checked + .check.is-white {
border-color: rgba(255, 255, 255, 0.9);
}
.switch.is-outlined:hover input[type=checkbox]:checked + .check.is-black {
border-color: rgba(10, 10, 10, 0.9);
}
.switch.is-outlined:hover input[type=checkbox]:checked + .check.is-light {
border-color: rgba(245, 245, 245, 0.9);
}
.switch.is-outlined:hover input[type=checkbox]:checked + .check.is-dark {
border-color: rgba(54, 54, 54, 0.9);
}
.switch.is-outlined:hover input[type=checkbox]:checked + .check.is-primary {
border-color: rgba(0, 209, 178, 0.9);
}
.switch.is-outlined:hover input[type=checkbox]:checked + .check.is-link {
border-color: rgba(72, 95, 199, 0.9);
}
.switch.is-outlined:hover input[type=checkbox]:checked + .check.is-info {
border-color: rgba(62, 142, 208, 0.9);
}
.switch.is-outlined:hover input[type=checkbox]:checked + .check.is-success {
border-color: rgba(72, 199, 142, 0.9);
}
.switch.is-outlined:hover input[type=checkbox]:checked + .check.is-warning {
border-color: rgba(255, 224, 138, 0.9);
}
.switch.is-outlined:hover input[type=checkbox]:checked + .check.is-danger {
border-color: rgba(241, 70, 104, 0.9);
}
.switch.is-small {
border-radius: 2px;
font-size: 0.75rem;
}
.switch.is-medium {
font-size: 1.25rem;
}
.switch.is-large {
font-size: 1.5rem;
}
.switch[disabled] {
opacity: 0.5;
cursor: not-allowed;
color: #7a7a7a;
}