134 lines
3.1 KiB
CSS
134 lines
3.1 KiB
CSS
[data-component="switch"] {
|
|
--switch-fill: 0px;
|
|
--switch-scale-x: 1;
|
|
--switch-x: 0px;
|
|
--switch-focus: 0px;
|
|
--switch-border: var(--border-weaker-base);
|
|
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
cursor: default;
|
|
|
|
[data-slot="switch-input"] {
|
|
position: absolute;
|
|
width: 1px;
|
|
height: 1px;
|
|
padding: 0;
|
|
margin: -1px;
|
|
overflow: hidden;
|
|
clip: rect(0, 0, 0, 0);
|
|
white-space: nowrap;
|
|
border-width: 0;
|
|
}
|
|
|
|
[data-slot="switch-control"] {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
position: relative;
|
|
z-index: 1;
|
|
width: 32px;
|
|
height: 18px;
|
|
flex-shrink: 0;
|
|
border-radius: 4px;
|
|
border: 1px solid var(--switch-border);
|
|
background: var(--surface-raised-base);
|
|
|
|
box-shadow: inset 0 0 0 var(--switch-fill) var(--surface-success-strong);
|
|
transition:
|
|
box-shadow 180ms,
|
|
border-color 180ms;
|
|
}
|
|
|
|
[data-slot="switch-thumb"] {
|
|
width: 16px;
|
|
height: 16px;
|
|
box-sizing: content-box;
|
|
|
|
border-radius: 3px;
|
|
background: var(--surface-raised-stronger);
|
|
|
|
/* shadows/shadow-xs */
|
|
box-shadow:
|
|
0 4px 8px -2px rgba(19, 16, 16, 0.2),
|
|
0 1px 2px 0 rgba(19, 16, 16, 0.15),
|
|
0 2px 3px 0 rgba(19, 16, 16, 0.2);
|
|
|
|
transform: translateX(var(--switch-x)) scaleX(var(--switch-scale-x));
|
|
transform-origin: left center;
|
|
transition:
|
|
transform 180ms,
|
|
background-color 180ms;
|
|
transition-timing-function: cubic-bezier(0.25, 0, 0.5, 1);
|
|
}
|
|
|
|
[data-slot="switch-label"] {
|
|
user-select: none;
|
|
color: var(--text-base);
|
|
font-family: var(--font-family-sans);
|
|
font-size: var(--font-size-small);
|
|
font-style: normal;
|
|
font-weight: var(--font-weight-regular);
|
|
line-height: var(--line-height-large);
|
|
letter-spacing: var(--letter-spacing-normal);
|
|
}
|
|
|
|
[data-slot="switch-description"] {
|
|
color: var(--text-base);
|
|
font-family: var(--font-family-sans);
|
|
font-size: 12px;
|
|
font-weight: var(--font-weight-regular);
|
|
line-height: var(--line-height-normal);
|
|
letter-spacing: var(--letter-spacing-normal);
|
|
}
|
|
|
|
[data-slot="switch-error"] {
|
|
color: var(--text-error);
|
|
font-family: var(--font-family-sans);
|
|
font-size: 12px;
|
|
font-weight: var(--font-weight-regular);
|
|
line-height: var(--line-height-normal);
|
|
letter-spacing: var(--letter-spacing-normal);
|
|
}
|
|
|
|
&:hover:not([data-disabled], [data-readonly]) {
|
|
--switch-scale-x: 1.1;
|
|
}
|
|
|
|
&:focus-within:not([data-readonly]) {
|
|
--switch-focus: 2px;
|
|
}
|
|
|
|
&[data-checked] {
|
|
--switch-fill: 14px;
|
|
--switch-x: 14px;
|
|
--switch-border: var(--border-success-strong);
|
|
}
|
|
|
|
&[data-checked] [data-slot="switch-thumb"] {
|
|
background-color: var(--surface-interactive-weak);
|
|
transform-origin: right center;
|
|
}
|
|
|
|
&[data-disabled] {
|
|
cursor: not-allowed;
|
|
}
|
|
|
|
&[data-disabled] [data-slot="switch-control"] {
|
|
background-color: var(--surface-disabled);
|
|
}
|
|
|
|
&[data-disabled] [data-slot="switch-thumb"] {
|
|
background-color: var(--icon-disabled);
|
|
}
|
|
|
|
&[data-invalid] [data-slot="switch-control"] {
|
|
border-color: var(--border-error);
|
|
}
|
|
|
|
&[data-readonly] {
|
|
cursor: default;
|
|
pointer-events: none;
|
|
}
|
|
}
|