diff --git a/core/src/components/label/label.tsx b/core/src/components/label/label.tsx index 05fbf41851..2bf557004f 100644 --- a/core/src/components/label/label.tsx +++ b/core/src/components/label/label.tsx @@ -16,6 +16,8 @@ import { createColorClasses } from '../../utils/theme'; scoped: true }) export class Label implements ComponentInterface { + private inRange = false; + @Element() el!: HTMLElement; /** @@ -39,6 +41,7 @@ export class Label implements ComponentInterface { @State() noAnimate = false; componentWillLoad() { + this.inRange = !!this.el.closest('ion-range'); this.noAnimate = (this.position === 'floating'); this.emitStyle(); } @@ -57,11 +60,17 @@ export class Label implements ComponentInterface { } private emitStyle() { - const position = this.position; - this.ionStyle.emit({ - 'label': true, - [`label-${position}`]: position !== undefined - }); + const { inRange, position } = this; + + // If the label is inside of a range we don't want + // to override the classes added by the label that + // is a direct child of the item + if (!inRange) { + this.ionStyle.emit({ + 'label': true, + [`label-${position}`]: position !== undefined + }); + } } render() { diff --git a/core/src/components/range/test/basic/index.html b/core/src/components/range/test/basic/index.html index 5c15d0f815..c1a1343cb7 100644 --- a/core/src/components/range/test/basic/index.html +++ b/core/src/components/range/test/basic/index.html @@ -85,6 +85,7 @@ + Stacked Label Start End