@ionic/core
Version:
Base components for Ionic
320 lines (289 loc) • 7.71 kB
CSS
:host {
/**
* @prop --bar-background: Background of the range bar
* @prop --bar-background-active: Background of the active range bar
* @prop --bar-height: Height of the range bar
* @prop --bar-border-radius: Border radius of the range bar
* @prop --height: Height of the range
* @prop --knob-background: Background of the range knob
* @prop --knob-border-radius: Border radius of the range knob
* @prop --knob-box-shadow: Box shadow of the range knob
* @prop --knob-size: Size of the range knob
* @prop --pin-background: Background of the range pin
* @prop --pin-color: Color of the range pin
*/
--knob-handle-size: calc(var(--knob-size) * 2);
display: flex;
position: relative;
flex: 3;
align-items: center;
font-family: var(--ion-font-family, inherit);
user-select: none;
z-index: 2;
}
:host(.range-disabled) {
pointer-events: none;
}
::slotted(ion-label) {
flex: initial;
}
::slotted(ion-icon[slot]) {
font-size: 24px;
}
.range-slider {
position: relative;
flex: 1;
width: 100%;
height: var(--height);
contain: size layout style;
cursor: grab;
touch-action: pan-y;
}
:host(.range-pressed) .range-slider {
cursor: grabbing;
}
.range-pin {
position: absolute;
background: var(--ion-color-base);
color: var(--ion-color-contrast);
text-align: center;
box-sizing: border-box;
}
.range-knob-handle {
left: 0;
top: calc((var(--height) - var(--knob-handle-size)) / 2);
margin-left: calc(0px - var(--knob-handle-size) / 2);
position: absolute;
width: var(--knob-handle-size);
height: var(--knob-handle-size);
text-align: center;
}
[dir=rtl] .range-knob-handle, :host-context([dir=rtl]) .range-knob-handle {
left: unset;
right: unset;
right: 0;
}
@supports (margin-inline-start: 0) or (-webkit-margin-start: 0) {
.range-knob-handle {
margin-left: unset;
-webkit-margin-start: calc(0px - var(--knob-handle-size) / 2);
margin-inline-start: calc(0px - var(--knob-handle-size) / 2);
}
}
[dir=rtl] .range-knob-handle, :host-context([dir=rtl]) .range-knob-handle {
/* stylelint-disable-next-line property-disallowed-list */
left: unset;
}
.range-knob-handle:active, .range-knob-handle:focus {
outline: none;
}
.range-bar {
border-radius: var(--bar-border-radius);
left: 0;
top: calc((var(--height) - var(--bar-height)) / 2);
position: absolute;
width: 100%;
height: var(--bar-height);
background: var(--bar-background);
pointer-events: none;
}
[dir=rtl] .range-bar, :host-context([dir=rtl]) .range-bar {
left: unset;
right: unset;
right: 0;
}
[dir=rtl] .range-bar, :host-context([dir=rtl]) .range-bar {
/* stylelint-disable-next-line property-disallowed-list */
left: unset;
}
.range-knob {
border-radius: var(--knob-border-radius);
left: calc(50% - var(--knob-size) / 2);
top: calc(50% - var(--knob-size) / 2);
position: absolute;
width: var(--knob-size);
height: var(--knob-size);
background: var(--knob-background);
box-shadow: var(--knob-box-shadow);
z-index: 2;
pointer-events: none;
}
[dir=rtl] .range-knob, :host-context([dir=rtl]) .range-knob {
left: unset;
right: unset;
right: calc(50% - var(--knob-size) / 2);
}
[dir=rtl] .range-knob, :host-context([dir=rtl]) .range-knob {
/* stylelint-disable-next-line property-disallowed-list */
left: unset;
}
:host(.range-pressed) .range-bar-active {
will-change: left, right;
}
:host(.in-item) {
width: 100%;
}
:host(.in-item) ::slotted(ion-label) {
align-self: center;
}
:host {
--knob-border-radius: 50%;
--knob-background: var(--bar-background-active);
--knob-box-shadow: none;
--knob-size: 18px;
--bar-height: 2px;
--bar-background: rgba(var(--ion-color-primary-rgb, 56, 128, 255), 0.26);
--bar-background-active: var(--ion-color-primary, #3880ff);
--bar-border-radius: 0;
--height: 42px;
--pin-background: var(--ion-color-primary, #3880ff);
--pin-color: var(--ion-color-primary-contrast, #fff);
padding-left: 14px;
padding-right: 14px;
padding-top: 8px;
padding-bottom: 8px;
font-size: 12px;
}
@supports (margin-inline-start: 0) or (-webkit-margin-start: 0) {
:host {
padding-left: unset;
padding-right: unset;
-webkit-padding-start: 14px;
padding-inline-start: 14px;
-webkit-padding-end: 14px;
padding-inline-end: 14px;
}
}
:host(.ion-color) .range-bar {
background: rgba(var(--ion-color-base-rgb), 0.26);
}
:host(.ion-color) .range-bar-active,
:host(.ion-color) .range-knob,
:host(.ion-color) .range-pin,
:host(.ion-color) .range-pin::before,
:host(.ion-color) .range-tick {
background: var(--ion-color-base);
color: var(--ion-color-contrast);
}
::slotted([slot=start]) {
margin-left: 0;
margin-right: 14px;
margin-top: 0;
margin-bottom: 0;
}
@supports (margin-inline-start: 0) or (-webkit-margin-start: 0) {
::slotted([slot=start]) {
margin-left: unset;
margin-right: unset;
-webkit-margin-start: 0;
margin-inline-start: 0;
-webkit-margin-end: 14px;
margin-inline-end: 14px;
}
}
::slotted([slot=end]) {
margin-left: 14px;
margin-right: 0;
margin-top: 0;
margin-bottom: 0;
}
@supports (margin-inline-start: 0) or (-webkit-margin-start: 0) {
::slotted([slot=end]) {
margin-left: unset;
margin-right: unset;
-webkit-margin-start: 14px;
margin-inline-start: 14px;
-webkit-margin-end: 0;
margin-inline-end: 0;
}
}
:host(.range-has-pin) {
padding-top: 28px;
}
.range-bar-active {
bottom: 0;
width: auto;
background: var(--bar-background-active);
}
.range-knob {
transform: scale(0.67);
transition-duration: 120ms;
transition-property: transform, background-color, border;
transition-timing-function: ease;
z-index: 2;
}
.range-tick {
position: absolute;
top: calc((var(--height) - var(--bar-height)) / 2);
width: var(--bar-height);
height: var(--bar-height);
background: var(--bar-background-active);
z-index: 1;
pointer-events: none;
}
.range-tick-active {
background: transparent;
}
.range-pin {
padding-left: 0;
padding-right: 0;
padding-top: 8px;
padding-bottom: 8px;
border-radius: 50%;
transform: translate3d(0, 0, 0) scale(0.01);
display: inline-block;
position: relative;
min-width: 28px;
height: 28px;
transition: transform 120ms ease, background 120ms ease;
background: var(--pin-background);
color: var(--pin-color);
text-align: center;
}
.range-pin::before {
left: 50%;
top: 3px;
margin-left: -13px;
/* stylelint-disable-next-line property-disallowed-list */
border-radius: 50% 50% 50% 0;
position: absolute;
width: 26px;
height: 26px;
transform: rotate(-45deg);
transition: background 120ms ease;
background: var(--pin-background);
content: "";
z-index: -1;
}
[dir=rtl] .range-pin::before, :host-context([dir=rtl]) .range-pin::before {
left: unset;
right: unset;
right: 50%;
}
@supports (margin-inline-start: 0) or (-webkit-margin-start: 0) {
.range-pin::before {
margin-left: unset;
-webkit-margin-start: -13px;
margin-inline-start: -13px;
}
}
[dir=rtl] .range-pin::before, :host-context([dir=rtl]) .range-pin::before {
/* stylelint-disable-next-line property-disallowed-list */
left: unset;
}
.range-knob-pressed .range-pin {
transform: translate3d(0, -24px, 0) scale(1);
}
:host(:not(.range-has-pin)) .range-knob-pressed .range-knob {
transform: scale(1);
}
:host(.range-disabled) .range-bar-active,
:host(.range-disabled) .range-bar,
:host(.range-disabled) .range-tick {
background-color: var(--ion-color-step-250, #bfbfbf);
}
:host(.range-disabled) .range-knob {
transform: scale(0.55);
outline: 5px solid #fff;
background-color: var(--ion-color-step-250, #bfbfbf);
}