@ionic/core
Version:
Base components for Ionic
158 lines (139 loc) • 4.28 kB
CSS
:host {
/**
* @prop --background: Background of the toggle
* @prop --background-checked: Background of the toggle when checked
* @prop --handle-background: Background of the toggle handle
* @prop --handle-background-checked: Background of the toggle handle when checked
*/
/* stylelint-disable-next-line declaration-no-important */
box-sizing: content-box ;
display: inline-block;
outline: none;
contain: content;
cursor: pointer;
touch-action: none;
user-select: none;
z-index: 2; }
:host(.ion-focused) input {
border: 2px solid #5e9ed6; }
:host(.toggle-disabled) {
pointer-events: none; }
button {
left: 0;
top: 0;
margin-left: 0;
margin-right: 0;
margin-top: 0;
margin-bottom: 0;
position: absolute;
width: 100%;
height: 100%;
border: 0;
background: transparent;
cursor: pointer;
appearance: none;
outline: none; }
:host-context([dir=rtl]) button {
right: 0; }
button::-moz-focus-inner {
border: 0; }
:host {
--background: var(--ion-item-background, var(--ion-background-color, #fff));
--background-checked: var(--ion-color-primary, #3880ff);
--handle-background: var(--ion-item-background, var(--ion-background-color, #fff));
--handle-background-checked: var(--ion-item-background, var(--ion-background-color, #fff));
box-sizing: content-box;
position: relative;
width: 51px;
height: 32px;
contain: strict; }
:host(.ion-color.toggle-checked) .toggle-icon {
background: var(--ion-color-base); }
:host(.ion-color.toggle-checked) .toggle-inner {
background: var(--ion-color-contrast); }
.toggle-icon {
border-radius: 16px;
display: block;
position: relative;
width: 100%;
height: 100%;
transform: translate3d(0, 0, 0);
transition: background-color 300ms;
background-color: var(--ion-color-step-50, #f2f2f2);
overflow: hidden;
pointer-events: none; }
.toggle-icon::before {
left: 2px;
right: 2px;
top: 2px;
bottom: 2px;
border-radius: 16px;
position: absolute;
transform: scale3d(1, 1, 1);
transition: transform 300ms;
background: var(--background);
content: ""; }
.toggle-inner {
left: 2px;
top: 2px;
border-radius: 14px;
position: absolute;
width: 28px;
height: 28px;
transition: transform 300ms, width 120ms ease-in-out 80ms, left 110ms ease-in-out 80ms, right 110ms ease-in-out 80ms;
background: var(--handle-background);
box-shadow: 0 3px 12px rgba(0, 0, 0, 0.16), 0 3px 1px rgba(0, 0, 0, 0.1);
will-change: transform;
contain: strict; }
:host-context([dir=rtl]) .toggle-inner {
right: 2px; }
:host(.toggle-checked) .toggle-icon {
background: var(--background-checked); }
:host(.toggle-activated) .toggle-icon::before,
:host(.toggle-checked) .toggle-icon::before {
transform: scale3d(0, 0, 0); }
:host(.toggle-checked) .toggle-inner {
transform: translate3d(19px, 0, 0);
background: var(--handle-background-checked); }
:host([dir=rtl].toggle-checked) .toggle-inner {
transform: translate3d(calc(-1 * 19px), 0, 0); }
:host(.toggle-activated.toggle-checked) .toggle-inner::before {
transform: scale3d(0, 0, 0); }
:host(.toggle-activated) .toggle-inner {
width: 34px; }
:host(.toggle-activated.toggle-checked) .toggle-inner {
left: -4px; }
:host([dir=rtl].toggle-activated.toggle-checked) .toggle-inner {
right: -4px; }
:host(.toggle-disabled) {
opacity: 0.3; }
:host(.in-item[slot]) {
margin-left: 0;
margin-right: 0;
margin-top: 0;
margin-bottom: 0;
padding-left: 16px;
padding-right: 8px;
padding-top: 6px;
padding-bottom: 5px; }
@supports (margin-inline-start: 0) or (-webkit-margin-start: 0) {
:host(.in-item[slot]) {
padding-left: unset;
padding-right: unset;
-webkit-padding-start: 16px;
padding-inline-start: 16px;
-webkit-padding-end: 8px;
padding-inline-end: 8px; } }
:host(.in-item[slot="start"]) {
padding-left: 0;
padding-right: 16px;
padding-top: 6px;
padding-bottom: 5px; }
@supports (margin-inline-start: 0) or (-webkit-margin-start: 0) {
:host(.in-item[slot="start"]) {
padding-left: unset;
padding-right: unset;
-webkit-padding-start: 0;
padding-inline-start: 0;
-webkit-padding-end: 16px;
padding-inline-end: 16px; } }