Skip to content

slider class

Displays and allows the user to set a value within a range.

Methods

__init__()

__init__(
    value=None,
    min=0,
    max=100,
    step=1,
    text_anchor="bottom",
    labels=None,
    continuous=True,
    change_delay=None, # App config
    width="300px",
    height=None,
    orientation="horizontal",
    lov=None,
    adapter=None, # <code>lambda x: str(x)</code>
    type=None, # Type name of the first lov element
    value_by_id=False,
    on_change=None,
    propagate=None, # App config
    active=True,
    id=None,
    properties=None,
    class_name=None,
    hover_text=None,
) -> None

Create a new slider element.

Parameters:

Name Type Description Default
value dynamic(Union[int, float, str, list[int], list[float], list[str]])

The value that is set for this slider.
If this slider is based on a lov then this property can be set to the lov element.
This value can also hold an array of numbers to indicate that the slider reflects a range (within the [min,max] domain) defined by several knobs that the user can set independently.
If this slider is based on a lov then this property can be set to an array of lov elements. The slider is then represented with several knobs, one for each lov value.

None
min Union[int, float]

The minimum value.
This is ignored when lov is defined.

0
max Union[int, float]

The maximum value.
This is ignored when lov is defined.

100
step Union[int, float]

The step value, which is the gap between two consecutive values the slider set. It is a good practice to have (max-min) being divisible by step.
This property is ignored when lov is defined.

1
text_anchor str

When the lov property is used, this property indicates the location of the label.
Possible values are:

  • "bottom"
  • "top"
  • "left"
  • "right"
  • "none" (no label is displayed)

bottom
labels Union[bool, dict[str, str]]

The labels for specific points of the slider.
If set to True, this slider uses the labels of the lov if there are any.
If set to a dictionary, the slider uses the dictionary keys as a lov key or index, and the associated value as the label.

None
continuous bool

If set to False, the control emits an on_change notification only when the mouse button is released, otherwise notifications are emitted during the cursor movements.
If lov is defined, the default value is False.

True
change_delay int

Minimum time between triggering two on_change callbacks.
The default value is defined at the application configuration level by the change_delay configuration option. if None or 0, there's no delay.

App config
width str

The width of the slider, in CSS units.

300px
height str

The height of the slider, in CSS units.
It defaults to the value of width when using the vertical orientation.

None
orientation str

The orientation of the slider.
Valid values are "horizontal" or "vertical".

horizontal
lov dict[str, Any]

The list of values. See the section on List of Values for more details.

None
adapter Union[str, Callable]

A function or the name of the function that transforms an element of lov into a tuple(id:str, label:Union[str, Icon]).
The default value is a function that returns the string representation of the lov element.

<code>lambda x: str(x)</code>
type str

This property is required if lov contains a non-specific type of data (e.g., a dictionary).
Then:

  • value must be of that type
  • lov must be an iterable containing elements of this type
  • The function set to adapter will receive an object of this type.

The default value is the type of the first element in lov.

Type name of the first lov element
value_by_id bool

If False, the selection value (in value) is the selected element in lov. If set to True, then value is set to the id of the selected element in lov.

False
on_change Union[str, Callable]

A function or the name of a function that is triggered when the value changes.
The callback function receives the following parameters:

  • state (State): the state instance.
  • var_name (str): the bound variable name.
  • value (Any): the updated value.

None
propagate bool

Determines whether the control's value is automatically reflected in the bound application variable.
The default value is defined at the application configuration level by the propagate configuration option.
If True, any change to the control's value is immediately reflected in the variable.

App config
active dynamic(bool)

Indicates if this element is active.
If False, the element is disabled, and user interaction is not allowed.

True
id str

The identifier assigned to the rendered HTML component.
This can be used in callbacks or to target the element for styling.

None
properties dict[str, Any]

A dictionary of additional properties that can be set to the element.

None
class_name dynamic(str)

A space-separated list of CSS class names to be applied to the generated HTML element.
These classes are added to the default taipy-slider class.

None
hover_text dynamic(str)

The text that is displayed when the user hovers over the element.

None