Slider Showcase

Example

Example width (width: 20, val: 3)

Example 3

Example 4

Example Nullable

Component Documentation

Component Name

Slider

Builder Function Name

create_slider_manager

Description

Displays a styled slider for numeric input, supporting single or multiple thumbs, highlighting ranges, and optional 'Set Null'.

Use like example

Config

PropertyTypeDefaultDescription
valnumber or number[]

0

Current value(s). If an array is provided, multiple thumbs appear.

minnumber

0

Minimum value range.

maxnumber

2

Maximum value range.

stepnumber

0.01

Value increment steps.

on_changefunction

Called with new value(s) when changed (pointer move or arrow key).

on_downfunction

Called with new value when pointer is pressed.

on_upfunction

Called with final value(s) when pointer is released.

labelstring or null

Label text displayed above the slider.

namestring

slider

Name attribute for potential form usage.

label_font_sizenumber

1.2

Size in rem for label text.

is_requiredboolean

false

Whether the field is required for form submission.

is_read_onlyboolean

false

If true, the slider can't be changed.

font_sizenumber

1

Base text size for the slider thumb.

is_disabledboolean

false

If true, slider is disabled. If val is null and is_nullable is false, defaults to true.

is_nullableboolean

false

If true, a 'Set Null' / 'Select Value' button toggles val between null and min.

colorCSS color

var(--primary-t)

Color used for highlight track background and thumb details.

is_shortboolean

false

If true, uses a more compact thumb design.

is_show_textboolean

true

If false, hides numeric text on thumb.

mlnumber

0

Margin-left in rem.

mrnumber

0

Margin-right in rem.

mtnumber

0

Margin-top in rem.

mbnumber

0

Margin-bottom in rem.

highlight_range_start_percentnumber

0

Optional highlight range start in percent (0-100).

highlight_range_end_percentnumber

0

Optional highlight range end in percent (0-100).

Methods

MethodDescriptionParametersReturns
init

Sets initial min, max, step, etc. Called once with the config. Also sets up thumbs from val.

No Params

set_val

Programmatically updates the slider's val (and thumbs).

No Params

handle_pointer_down

Begins tracking pointer for a slider thumb drag.

No Params

handle_pointer_move

Moves the closest thumb to the pointer's position.

No Params

handle_pointer_up

Finishes the drag, calls on_up with final value(s).

No Params

handle_thumb_keydown

Moves the thumb left/right by step when arrow keys pressed.

No Params

set_loading_i

Sets the thumb index to display loading state.

No Params

set_error_i

Sets the thumb index to display error state.

No Params

set_min

Updates the slider's min bound.

No Params

set_max

Updates the slider's max bound.

No Params

set_step

Updates the slider's step value.

No Params

Returned Properties

PropertyTypeDescription
valnumber or number[]

Current value(s) after pointer move/arrow key changes.

working_valarray

Internal slider thumb(s) values.

loading_inumber or null

Thumb index that is loading, if any. Setting triggers loading state for that thumb.

error_inumber or null

Thumb index that has an error, if any.

toggle_null_button_managerobject

Button manager for toggling null if is_nullable is true.

icon
Sponsored byContibase