mirror of
https://github.com/shoelace-style/webawesome.git
synced 2026-01-12 20:19:13 +00:00
336 lines
8.2 KiB
CSS
336 lines
8.2 KiB
CSS
/*! Switches */
|
|
|
|
.switch {
|
|
font-size: var(--switch-font-size);
|
|
position: relative;
|
|
|
|
& input {
|
|
position: absolute;
|
|
height: 1px;
|
|
width: 1px;
|
|
background: none;
|
|
border: 0;
|
|
clip: rect(0 0 0 0);
|
|
clip-path: inset(50%);
|
|
overflow: hidden;
|
|
padding: 0;
|
|
|
|
& + label {
|
|
position: relative;
|
|
min-width: calc(var(--switch-height) * 2);
|
|
border-radius: var(--switch-border-radius);
|
|
height: var(--switch-height);
|
|
line-height: var(--switch-height);
|
|
display: inline-block;
|
|
cursor: pointer;
|
|
outline: none;
|
|
user-select: none;
|
|
vertical-align: middle;
|
|
text-indent: calc(var(--switch-height) * 2 + .5rem);
|
|
}
|
|
|
|
& + label::before,
|
|
& + label::after {
|
|
content: '';
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
width: calc(var(--switch-height) * 2);
|
|
bottom: 0;
|
|
display: block;
|
|
}
|
|
|
|
& + label::before {
|
|
right: 0;
|
|
background-color: var(--switch-bg-color);
|
|
border-radius: var(--switch-border-radius);
|
|
transition: var(--switch-speed) all;
|
|
}
|
|
|
|
& + label::after {
|
|
top: var(--switch-thumb-spacing);
|
|
left: var(--switch-thumb-spacing);
|
|
width: calc(var(--switch-height) - var(--switch-thumb-spacing) * 2);
|
|
height: calc(var(--switch-height) - var(--switch-thumb-spacing) * 2);
|
|
border-radius: var(--switch-thumb-border-radius);
|
|
background-color: var(--switch-thumb-color);
|
|
transition: var(--switch-speed) margin;
|
|
}
|
|
|
|
&:checked + label::before {
|
|
background-color: var(--switch-color);
|
|
}
|
|
|
|
&:checked + label::after {
|
|
margin-left: var(--switch-height);
|
|
}
|
|
|
|
&:focus + label::before {
|
|
outline: none;
|
|
box-shadow: 0 0 0 var(--switch-focus-width) color(var(--switch-color) alpha(50%));
|
|
}
|
|
|
|
&:disabled + label {
|
|
opacity: .5;
|
|
cursor: not-allowed;
|
|
}
|
|
}
|
|
|
|
& + .switch {
|
|
margin-left: 1rem;
|
|
}
|
|
|
|
/* Sizes */
|
|
&.switch-xs {
|
|
font-size: var(--switch-font-size-xs);
|
|
|
|
& input {
|
|
& + label {
|
|
min-width: calc(var(--switch-height-xs) * 2);
|
|
height: var(--switch-height-xs);
|
|
line-height: var(--switch-height-xs);
|
|
text-indent: calc(var(--switch-height-xs) * 2 + .5rem);
|
|
}
|
|
|
|
& + label::before,
|
|
& + label::after {
|
|
width: calc(var(--switch-height-xs) * 2);
|
|
}
|
|
|
|
& + label::after {
|
|
width: calc(var(--switch-height-xs) - var(--switch-thumb-spacing) * 2);
|
|
height: calc(var(--switch-height-xs) - var(--switch-thumb-spacing) * 2);
|
|
}
|
|
|
|
&:checked + label::after {
|
|
margin-left: var(--switch-height-xs);
|
|
}
|
|
}
|
|
}
|
|
|
|
&.switch-sm {
|
|
font-size: var(--switch-font-size-sm);
|
|
|
|
& input {
|
|
& + label {
|
|
min-width: calc(var(--switch-height-sm) * 2);
|
|
height: var(--switch-height-sm);
|
|
line-height: var(--switch-height-sm);
|
|
text-indent: calc(var(--switch-height-sm) * 2 + .5rem);
|
|
}
|
|
|
|
& + label::before,
|
|
& + label::after {
|
|
width: calc(var(--switch-height-sm) * 2);
|
|
}
|
|
|
|
& + label::after {
|
|
width: calc(var(--switch-height-sm) - var(--switch-thumb-spacing) * 2);
|
|
height: calc(var(--switch-height-sm) - var(--switch-thumb-spacing) * 2);
|
|
}
|
|
|
|
&:checked + label::after {
|
|
margin-left: var(--switch-height-sm);
|
|
}
|
|
}
|
|
}
|
|
|
|
&.switch-lg {
|
|
font-size: var(--switch-font-size-lg);
|
|
|
|
& input {
|
|
& + label {
|
|
min-width: calc(var(--switch-height-lg) * 2);
|
|
height: var(--switch-height-lg);
|
|
line-height: var(--switch-height-lg);
|
|
text-indent: calc(var(--switch-height-lg) * 2 + .5rem);
|
|
}
|
|
|
|
& + label::before,
|
|
& + label::after {
|
|
width: calc(var(--switch-height-lg) * 2);
|
|
}
|
|
|
|
& + label::after {
|
|
width: calc(var(--switch-height-lg) - var(--switch-thumb-spacing) * 2);
|
|
height: calc(var(--switch-height-lg) - var(--switch-thumb-spacing) * 2);
|
|
}
|
|
|
|
&:checked + label::after {
|
|
margin-left: var(--switch-height-lg);
|
|
}
|
|
}
|
|
}
|
|
|
|
&.switch-xl {
|
|
font-size: var(--switch-font-size-xl);
|
|
|
|
& input {
|
|
& + label {
|
|
min-width: calc(var(--switch-height-xl) * 2);
|
|
height: var(--switch-height-xl);
|
|
line-height: var(--switch-height-xl);
|
|
text-indent: calc(var(--switch-height-xl) * 2 + .5rem);
|
|
}
|
|
|
|
& + label::before,
|
|
& + label::after {
|
|
width: calc(var(--switch-height-xl) * 2);
|
|
}
|
|
|
|
& + label::after {
|
|
width: calc(var(--switch-height-xl) - var(--switch-thumb-spacing) * 2);
|
|
height: calc(var(--switch-height-xl) - var(--switch-thumb-spacing) * 2);
|
|
}
|
|
|
|
&:checked + label::after {
|
|
margin-left: var(--switch-height-xl);
|
|
}
|
|
}
|
|
}
|
|
|
|
/* Variations */
|
|
&.switch-secondary {
|
|
& input {
|
|
background-color: var(--switch-bg-color-secondary);
|
|
|
|
& + label::after { background-color: var(--switch-thumb-color-secondary); }
|
|
& + label::before { background-color: var(--switch-bg-color-secondary); }
|
|
&:checked + label::before { background-color: var(--switch-color-secondary); }
|
|
&:focus + label::before { box-shadow: 0 0 0 var(--switch-focus-width) color(var(--switch-color-secondary) alpha(50%)); }
|
|
}
|
|
}
|
|
|
|
&.switch-success {
|
|
& input {
|
|
background-color: var(--switch-bg-color-success);
|
|
|
|
& + label::after {
|
|
background-color: var(--switch-thumb-color-success);
|
|
}
|
|
|
|
& + label::before {
|
|
background-color: var(--switch-bg-color-success);
|
|
}
|
|
|
|
&:checked + label::before {
|
|
background-color: var(--switch-color-success);
|
|
}
|
|
|
|
&:focus + label::before {
|
|
box-shadow: 0 0 0 var(--switch-focus-width) color(var(--switch-color-success) alpha(50%));
|
|
}
|
|
}
|
|
}
|
|
|
|
&.switch-info {
|
|
& input {
|
|
background-color: var(--switch-bg-color-info);
|
|
|
|
& + label::after {
|
|
background-color: var(--switch-thumb-color-info);
|
|
}
|
|
|
|
& + label::before {
|
|
background-color: var(--switch-bg-color-info);
|
|
}
|
|
|
|
&:checked + label::before {
|
|
background-color: var(--switch-color-info);
|
|
}
|
|
|
|
&:focus + label::before {
|
|
box-shadow: 0 0 0 var(--switch-focus-width) color(var(--switch-color-info) alpha(50%));
|
|
}
|
|
}
|
|
}
|
|
|
|
&.switch-warning {
|
|
& input {
|
|
background-color: var(--switch-bg-color-warning);
|
|
|
|
& + label::after {
|
|
background-color: var(--switch-thumb-color-warning);
|
|
}
|
|
|
|
& + label::before {
|
|
background-color: var(--switch-bg-color-warning);
|
|
}
|
|
|
|
&:checked + label::before {
|
|
background-color: var(--switch-color-warning);
|
|
}
|
|
|
|
&:focus + label::before {
|
|
box-shadow: 0 0 0 var(--switch-focus-width) color(var(--switch-color-warning) alpha(50%));
|
|
}
|
|
}
|
|
}
|
|
|
|
&.switch-danger {
|
|
& input {
|
|
background-color: var(--switch-bg-color-danger);
|
|
|
|
& + label::after {
|
|
background-color: var(--switch-thumb-color-danger);
|
|
}
|
|
|
|
& + label::before {
|
|
background-color: var(--switch-bg-color-danger);
|
|
}
|
|
|
|
&:checked + label::before {
|
|
background-color: var(--switch-color-danger);
|
|
}
|
|
|
|
&:focus + label::before {
|
|
box-shadow: 0 0 0 var(--switch-focus-width) color(var(--switch-color-danger) alpha(50%));
|
|
}
|
|
}
|
|
}
|
|
|
|
&.switch-light {
|
|
& input {
|
|
background-color: var(--switch-bg-color-light);
|
|
|
|
& + label::after {
|
|
background-color: var(--switch-thumb-color-light);
|
|
}
|
|
|
|
& + label::before {
|
|
background-color: var(--switch-bg-color-light);
|
|
}
|
|
|
|
&:checked + label::before {
|
|
background-color: var(--switch-color-light);
|
|
}
|
|
|
|
&:focus + label::before {
|
|
box-shadow: 0 0 0 var(--switch-focus-width) color(var(--switch-color-light) alpha(50%));
|
|
}
|
|
}
|
|
}
|
|
|
|
&.switch-dark {
|
|
& input {
|
|
background-color: var(--switch-bg-color-dark);
|
|
|
|
& + label::after {
|
|
background-color: var(--switch-thumb-color-dark);
|
|
}
|
|
|
|
& + label::before {
|
|
background-color: var(--switch-bg-color-dark);
|
|
}
|
|
|
|
&:checked + label::before {
|
|
background-color: var(--switch-color-dark);
|
|
}
|
|
|
|
&:focus + label::before {
|
|
box-shadow: 0 0 0 var(--switch-focus-width) color(var(--switch-color-dark) alpha(50%));
|
|
}
|
|
}
|
|
}
|
|
}
|