Decorative elements can be passed into the start or end slots of the range. This is useful for adding icons such as low volume or high volume icons. Since these elements are decorative, they should not be announced by assistive technology such as screen readers.
If the directionality of the document is set to left to right, the contents slotted to the start position will display to the left of the range, where as contents slotted to the end position will display to the right of the range. In right to left (rtl) directionality, the contents slotted to the start position will display to the right of the range, where as contents slotted to the end position will display to the left of the range.
A simpler range syntax was introduced in Ionic 7.0. This new syntax reduces the boilerplate required to setup an range, resolves accessibility issues, and improves the developer experience.
Developers can perform this migration one range at a time. While developers can continue using the legacy syntax, we recommend migrating as soon as possible.
Using the modern syntax involves removing the ion-label and passing the label directly inside of ion-range using slot="label". The placement of the label can be configured using the labelPlacement property on ion-range.
JavaScript
Angular
React
Vue
<!-- Basic --> <!-- Before --> <ion-item> <ion-label>Notifications</ion-label> <ion-range></ion-range> </ion-item> <!-- After --> <ion-item> <ion-range> <divslot="label">Notifications</div> </ion-range> </ion-item> <!-- Fixed Labels --> <!-- Before --> <ion-item> <ion-labelposition="fixed">Notifications</ion-label> <ion-range></ion-range> </ion-item> <!-- After --> <ion-item> <ion-rangelabel-placement="fixed"> <divslot="label">Notifications</div> </ion-range> </ion-item> <!-- Range at the start of line, Label at the end of line --> <!-- Before --> <ion-item> <ion-labelslot="end">Notifications</ion-label> <ion-range></ion-range> </ion-item> <!-- After --> <ion-item> <ion-rangelabel-placement="end"> <divslot="label">Notifications</div> </ion-range> </ion-item>
<!-- Basic --> <!-- Before --> <ion-item> <ion-label>Notifications</ion-label> <ion-range></ion-range> </ion-item> <!-- After --> <ion-item> <ion-range> <divslot="label">Notifications</div> </ion-range> </ion-item> <!-- Fixed Labels --> <!-- Before --> <ion-item> <ion-labelposition="fixed">Notifications</ion-label> <ion-range></ion-range> </ion-item> <!-- After --> <ion-item> <ion-rangelabelPlacement="fixed"> <divslot="label">Notifications</div> </ion-range> </ion-item> <!-- Range at the start of line, Label at the end of line --> <!-- Before --> <ion-item> <ion-labelslot="end">Notifications</ion-label> <ion-range></ion-range> </ion-item> <!-- After --> <ion-item> <ion-rangelabelPlacement="end"> <divslot="label">Notifications</div> </ion-range> </ion-item>
{/* Basic */} {/* Before */} <IonItem> <IonLabel>Notifications</IonLabel> <IonRange></IonRange> </IonItem> {/* After */} <IonItem> <IonRange> <divslot="label">Notifications</div> </IonRange> </IonItem> {/* Fixed Labels */} {/* Before */} <IonItem> <IonLabelposition="fixed">Notifications</IonLabel> <IonRange></IonRange> </IonItem> {/* After */} <IonItem> <IonRangelabelPlacement="fixed"> <divslot="label">Notifications</div> </IonRange> </IonItem> {/* Range at the start of line, Label at the end of line */} {/* Before */} <IonItem> <IonLabelslot="end">Notifications</IonLabel> <IonRange></IonRange> </IonItem> {/* After */} <IonItem> <IonRangelabelPlacement="end"> <divslot="label">Notifications</div> </IonRange> </IonItem>
<!-- Basic --> <!-- Before --> <ion-item> <ion-label>Notifications</ion-label> <ion-range></ion-range> </ion-item> <!-- After --> <ion-item> <ion-range> <divslot="label">Notifications</div> </ion-range> </ion-item> <!-- Fixed Labels --> <!-- Before --> <ion-item> <ion-labelposition="fixed">Notifications</ion-label> <ion-range></ion-range> </ion-item> <!-- After --> <ion-item> <ion-rangelabel-placement="fixed"> <divslot="label">Notifications</div> </ion-range> </ion-item> <!-- Range at the start of line, Label at the end of line --> <!-- Before --> <ion-item> <ion-labelslot="end">Notifications</ion-label> <ion-range></ion-range> </ion-item> <!-- After --> <ion-item> <ion-rangelabel-placement="end"> <divslot="label">Notifications</div> </ion-range> </ion-item>
note
In past versions of Ionic, ion-item was required for ion-range to function properly. Starting in Ionic 7.0, ion-range should only be used in an ion-item when the item is placed in an ion-list. Additionally, ion-item is no longer required for ion-range to function properly.
Ionic uses heuristics to detect if an app is using the modern range syntax. In some instances, it may be preferable to continue using the legacy syntax. Developers can set the legacy property on ion-range to true to force that instance of the range to use the legacy syntax.
The start position of the range active bar. This feature is only available with a single knob (dualKnobs="false"). Valid values are greater than or equal to the min value and less than or equal to the max value.
The color to use from your application's color palette. Default options are: "primary", "secondary", "tertiary", "success", "warning", "danger", "light", "medium", and "dark". For more information on colors, see theming.
Where to place the label relative to the range. "start": The label will appear to the left of the range in LTR and to the right in RTL. "end": The label will appear to the right of the range in LTR and to the left in RTL. "fixed": The label has the same behavior as "start" except it also has a fixed width. Long text will be truncated with ellipses ("...").
Set the legacy property to true to forcibly use the legacy form control markup. Ionic will only opt components in to the modern form markup when they are using either the aria-label attribute or the label property. As a result, the legacy property should only be used as an escape hatch when you want to avoid this automatic opt-in behavior. Note that this property will be removed in an upcoming major release of Ionic, and all form components will be opted-in to using the modern form markup.
The ionChange event is fired for <ion-range> elements when the user modifies the element's value: - When the user releases the knob after dragging; - When the user moves the knob with keyboard arrows
ionChange is not fired when the value is changed programmatically.
ionFocus
レンジのフォーカスが合ったときに発します。
ionInput
The ionInput event is fired for <ion-range> elements when the value is modified. Unlike ionChange, ionInput is fired continuously while the user is dragging the knob.
ionKnobMoveEnd
Emitted when the user finishes moving the range knob, whether through mouse drag, touch gesture, or keyboard interaction.
ionKnobMoveStart
Emitted when the user starts moving the range knob, whether through mouse drag, touch gesture, or keyboard interaction.