com.vaadin.flow.component.html.

Class RangeInput

All Implemented Interfaces:

AttachNotifier, BlurNotifier<RangeInput>, DetachNotifier, Focusable<RangeInput>, FocusNotifier<RangeInput>, HasAriaLabel, HasElement, HasEnabled, HasSize, HasStyle, HasValue<AbstractField.ComponentValueChangeEvent<RangeInput,Double>,Double>, HasValueAndElement<AbstractField.ComponentValueChangeEvent<RangeInput,Double>,Double>, HasValueChangeMode, Serializable

Creates a new input element with type "range".

Note: Slider doesn't support the read-only mode and will disable itself instead.

See Also:

  • Constructor Details

    • RangeInput

      public RangeInput()

      Creates a new slider, with ON_CHANGE value change mode.

    • RangeInput

      public RangeInput(ValueChangeMode valueChangeMode)

      Creates a new slider.

      Parameters:

      valueChangeMode - initial value change mode, or null to disable the value synchronization

  • Method Details

    • getValueChangeMode

      public ValueChangeMode getValueChangeMode()

      Description copied from interface: HasValueChangeMode

      Gets current value change mode of the component.

      Specified by:

      getValueChangeMode in interface HasValueChangeMode

      Returns:

      current value change mode of the component, or null if the value is not synchronized

    • setValueChangeMode

      public void setValueChangeMode(ValueChangeMode valueChangeMode)

      Description copied from interface: HasValueChangeMode

      Sets new value change mode for the component.

      Specified by:

      setValueChangeMode in interface HasValueChangeMode

      Parameters:

      valueChangeMode - new value change mode, or null to disable the value synchronization

    • setValueChangeTimeout

      public void setValueChangeTimeout(int valueChangeTimeout)

      Description copied from interface: HasValueChangeMode

      Sets how often HasValue.ValueChangeEvents are triggered when the ValueChangeMode is set to ValueChangeMode.LAZY, or ValueChangeMode.TIMEOUT.

      Implementations should use ValueChangeMode.applyChangeTimeout(ValueChangeMode, int, DomListenerRegistration).

      Specified by:

      setValueChangeTimeout in interface HasValueChangeMode

      Parameters:

      valueChangeTimeout - the timeout in milliseconds of how often HasValue.ValueChangeEvents are triggered.

    • getValueChangeTimeout

      public int getValueChangeTimeout()

      Returns the currently set timeout, for how often HasValue.ValueChangeEvents are triggered when the ValueChangeMode is set to ValueChangeMode.LAZY, or ValueChangeMode.TIMEOUT.

      The default value is HasValueChangeMode.DEFAULT_CHANGE_TIMEOUT.

      Specified by:

      getValueChangeTimeout in interface HasValueChangeMode

      Returns:

      the timeout in milliseconds of how often HasValue.ValueChangeEvents are triggered.

    • getMin

      public double getMin()

      Gets the minimum value.

      Returns:

      the minimum value, defaults to 0.

    • setMin

      public void setMin(double min)

      Sets the new minimum value.

      Parameters:

      min - the minimum value.

    • getMax

      public double getMax()

      Gets the maximum value.

      Returns:

      the maximum value, defaults to 100.

    • setMax

      public void setMax(double max)

      Sets the new maximum value.

      Parameters:

      max - the maximum value.

    • getStep

      public Double getStep()

      The step attribute is a number that specifies the granularity that the value must adhere to.

      The step attribute can also be set to null. This step value means that no stepping interval is implied and any value is allowed in the specified range

      The default stepping value for range inputs is 1, allowing only integers to be entered, unless the stepping base is not an integer; for example, if you set min to -10 and value to 1.5, then a step of 1 will allow only values such as 1.5, 2.5, 3.5,? in the positive direction and -0.5, -1.5, -2.5,? in the negative direction.

      Returns:

      the current step value, defaults to 1.

    • setStep

      public void setStep(Double step)

      The step attribute is a number that specifies the granularity that the value must adhere to.

      The step attribute can also be set to null. This step value means that no stepping interval is implied and any value is allowed in the specified range

      The default stepping value for range inputs is 1, allowing only integers to be entered, unless the stepping base is not an integer; for example, if you set min to -10 and value to 1.5, then a step of 1 will allow only values such as 1.5, 2.5, 3.5,? in the positive direction and -0.5, -1.5, -2.5,? in the negative direction.

      Parameters:

      step - the new step value, may be null.

    • setOrientation

      public void setOrientation(RangeInput.Orientation orientation)

      Sets the orientation of the range slider.

      Non-standard Attribute. Since the vertical orientation is not standardized yet, this feature is not guaranteed to work on every browser. We found this feature to work on Firefox 120+, Chromium 119+, Edge 119+ and Safari 17.1+.

      The orient attribute defines the orientation of the range slider. Values include horizontal, meaning the range is rendered horizontally, and vertical, where the range is rendered vertically.

      Parameters:

      orientation - the orientation, not null. Defaults to RangeInput.Orientation.HORIZONTAL.

    • getOrientation

      public RangeInput.Orientation getOrientation()

      Gets the orientation of the range slider.

      Non-standard Attribute.

      The orient attribute defines the orientation of the range slider. Values include horizontal, meaning the range is rendered horizontally, and vertical, where the range is rendered vertically.

      Returns:

      the current orientation, never null.

    • setReadOnly

      public void setReadOnly(boolean readOnly)

      Description copied from interface: HasValue

      Sets the read-only mode of this HasValue to given mode. The user can't change the value when in read-only mode.

      A HasValue with a visual component in read-only mode typically looks visually different to signal to the user that the value cannot be edited.

      Specified by:

      setReadOnly in interface HasValue<AbstractField.ComponentValueChangeEvent<RangeInput,Double>,Double>

      Specified by:

      setReadOnly in interface HasValueAndElement<AbstractField.ComponentValueChangeEvent<RangeInput,Double>,Double>

      Parameters:

      readOnly - a boolean value specifying whether the component is put read-only mode or not

    • isReadOnly

      public boolean isReadOnly()

      Description copied from interface: HasValue

      Returns whether this HasValue is in read-only mode or not.

      Specified by:

      isReadOnly in interface HasValue<AbstractField.ComponentValueChangeEvent<RangeInput,Double>,Double>

      Specified by:

      isReadOnly in interface HasValueAndElement<AbstractField.ComponentValueChangeEvent<RangeInput,Double>,Double>

      Returns:

      false if the user can modify the value, true if not.

    • setEnabled

      public void setEnabled(boolean enabled)

      Description copied from interface: HasEnabled

      Sets the UI object explicitly disabled or enabled.

      Specified by:

      setEnabled in interface HasEnabled

      Parameters:

      enabled - if false then explicitly disables the object, if true then enables the object so that its state depends on parent

    • isEnabled

      public boolean isEnabled()

      Description copied from interface: HasEnabled

      Returns whether the object is enabled or disabled.

      Object may be enabled by itself by but if its ascendant is disabled then it's considered as (implicitly) disabled.

      Specified by:

      isEnabled in interface HasEnabled

      Returns:

      enabled state of the object