@gravity-ui/uikit
Version:
Gravity UI base styling and components
91 lines • 2.27 kB
CSS
@charset "UTF-8";
.g-switch {
position: relative;
}
.g-switch__control {
opacity: 0;
cursor: pointer;
}
.g-switch__indicator {
display: inline-block;
position: relative;
}
.g-switch__indicator::before {
content: "";
position: absolute;
inset: 0;
background-color: var(--g-color-base-generic-medium);
transition: background 0.1s linear;
}
.g-switch__indicator::after {
content: " ";
visibility: hidden;
}
.g-switch__slider {
position: absolute;
content: "";
border-radius: 50%;
background-color: var(--g-color-base-background);
transition: transform 0.15s ease-out;
}
.g-switch__outline {
position: absolute;
inset-block-start: 0;
inset-inline-start: 0;
width: 100%;
height: 100%;
background: none;
pointer-events: none;
}
.g-switch__control:focus-visible + .g-switch__outline {
outline: 2px solid var(--g-color-line-focus);
}
.g-switch_size_m .g-switch__indicator,
.g-switch_size_m .g-switch__indicator::before,
.g-switch_size_m .g-switch__outline {
width: 36px;
height: 20px;
border-radius: 10px;
}
.g-switch_size_m .g-switch__slider {
inset-block-start: 2px;
inset-inline-start: 2px;
width: 16px;
height: 16px;
}
.g-switch_size_m .g-switch__text {
margin-block-start: 3px;
}
.g-switch_size_l .g-switch__indicator,
.g-switch_size_l .g-switch__indicator::before,
.g-switch_size_l .g-switch__outline {
width: 42px;
height: 24px;
border-radius: 12px;
}
.g-switch_size_l .g-switch__slider {
inset-block-start: 3px;
inset-inline-start: 3px;
width: 18px;
height: 18px;
}
.g-switch_size_l .g-switch__text {
margin-block-start: 4px;
}
.g-switch:hover .g-switch__indicator::before {
background-color: var(--g-color-base-generic-medium-hover);
}
.g-switch_checked .g-switch__slider {
--_--translate-x: calc(100% * var(--g-flow-direction));
transform: translateX(var(--_--translate-x));
}
.g-switch_checked .g-switch__indicator::before, .g-switch_checked:hover .g-switch__indicator::before {
background-color: var(--g-color-base-brand);
}
.g-switch_disabled .g-switch__indicator::before {
background-color: var(--g-color-base-generic-accent-disabled);
}
.g-switch_disabled.g-switch_checked .g-switch__indicator::before {
background-color: var(--g-color-base-brand);
opacity: 0.5;
}