wijjit.elements.input.slider.Slider

class wijjit.elements.input.slider.Slider(id=None, classes=None, tab_index=None, min_val=0, max_val=100, value=None, step=1, width=20, float_mode=False, label=None, show_value=True, bind=True)[source]

Slider input element for numeric value selection.

A slider provides a visual bar with a draggable handle for selecting values within a range. Supports keyboard navigation (arrows, home/end) and mouse interaction (click to set, drag to adjust).

Parameters:
  • id (str, optional) – Element identifier for state binding

  • min_val (float, optional) – Minimum value (default: 0)

  • max_val (float, optional) – Maximum value (default: 100)

  • value (float, optional) – Initial value (defaults to min_val)

  • step (float, optional) – Step increment for keyboard navigation (default: 1)

  • width (int, optional) – Visual width of slider track in characters (default: 20)

  • float_mode (bool, optional) – If True, value property returns float; if False, returns int (default: False)

  • label (str, optional) – Optional label displayed before slider

  • show_value (bool, optional) – Display current value after slider (default: True)

  • classes (str | list[str] | set[str] | None)

  • tab_index (int | None)

  • bind (bool | str)

Variables:
  • min_val (float) – Minimum value

  • max_val (float) – Maximum value

  • step (float) – Step increment

  • width (int) – Track width

  • float_mode (bool) – Float mode flag

  • label (str or None) – Label text

  • show_value (bool) – Show value flag

  • on_change (callable or None) – Callback (old_value, new_value) when value changes

  • on_slide_start (callable or None) – Callback when drag operation begins

  • on_slide_end (callable or None) – Callback when drag operation ends

  • action (str or None) – Action ID to dispatch (set by template extension)

  • bind (bool) – Whether to auto-bind to state[id] (default: True)

Notes

Keyboard controls: - Left/Right: Decrement/increment by step - Home/End: Jump to min/max value

Mouse controls: - Click on track: Set value at clicked position - Drag handle: Smooth value adjustment

__init__(id=None, classes=None, tab_index=None, min_val=0, max_val=100, value=None, step=1, width=20, float_mode=False, label=None, show_value=True, bind=True)[source]
Parameters:
Return type:

None

Methods

__init__([id, classes, tab_index, min_val, ...])

add_class(class_name)

Add a CSS class to this element.

apply_props(props)

Apply props from a VNode, skipping ephemeral props.

get_ephemeral_state()

Get ephemeral state for reconciliation.

get_hardware_cursor_position()

Absolute screen cell where the hardware terminal cursor should park.

get_height_for_width(width)

Return the height this element needs when laid out at width.

get_intrinsic_size()

Get the intrinsic (preferred) size of the slider.

handle_key(key)

Handle keyboard input.

handle_mouse(event)

Handle mouse input for click and drag.

has_class(class_name)

Check if element has a CSS class.

on_blur()

Called when element loses focus.

on_focus()

Called when element gains focus.

on_hover_enter()

Called when mouse enters element.

on_hover_exit()

Called when mouse exits element.

on_mount()

Called when element is first added to the element tree.

on_unmount()

Called when element is removed from the element tree.

on_update(changed_props)

Called when element props are updated during reconciliation.

remove_class(class_name)

Remove a CSS class from this element.

render_signature()

Paint memo for the skip-unchanged fast path.

render_to(ctx)

Render slider to paint context.

restore_ephemeral_state(state)

Restore ephemeral state after reconciliation.

set_bounds(bounds)

Set the element's screen bounds.

toggle_class(class_name)

Toggle a CSS class on this element.

Attributes

HANDLE_CHAR

HANDLE_CHAR_ASCII

LEFT_CAP

LEFT_CAP_ASCII

RIGHT_CAP

RIGHT_CAP_ASCII

TRACK_CHAR

TRACK_CHAR_ASCII

captures_tab

Whether this element wants the Tab key instead of focus movement.

parent_frame

Get the parent Frame if this element is inside a scrollable frame.

supports_dynamic_sizing

Whether this element supports dynamic sizing.

value

Get current value, cast to int if not float_mode.

TRACK_CHAR = '─'
HANDLE_CHAR = '█'
LEFT_CAP = '├'
RIGHT_CAP = '┤'
TRACK_CHAR_ASCII = '-'
HANDLE_CHAR_ASCII = '#'
LEFT_CAP_ASCII = '['
RIGHT_CAP_ASCII = ']'
property value: float | int

Get current value, cast to int if not float_mode.

Returns:

Current slider value

Return type:

float or int

render_signature()[source]

Paint memo for the skip-unchanged fast path.

Captures the backing value and range (which fix the handle position), the track width, and the label/value-display flags. focused (handle color) is folded into _style_signature(). See wijjit.elements.base.Element.render_signature().

Return type:

Any

render_to(ctx)[source]

Render slider to paint context.

Parameters:
  • ctx (PaintContext) – Paint context with buffer, style resolver, and bounds

  • styles (Theme)

  • classes (This element uses the following theme style)

  • slider (-)

  • slider:focus (-)

  • slider.handle (-)

  • slider.handle:focus (-)

  • slider.label (-)

  • slider.value (-)

Return type:

None

get_intrinsic_size()[source]

Get the intrinsic (preferred) size of the slider.

Returns:

(width, height) based on track width, label, and value display

Return type:

tuple[int, int]

handle_key(key)[source]

Handle keyboard input.

Parameters:

key (Key) – Key press to handle

Returns:

True if key was handled

Return type:

bool

async handle_mouse(event)[source]

Handle mouse input for click and drag.

Parameters:

event (MouseEvent) – Mouse event to handle

Returns:

True if event was handled

Return type:

bool

get_ephemeral_state()[source]

Get ephemeral state for reconciliation.

Returns:

State that should survive re-renders

Return type:

dict

restore_ephemeral_state(state)[source]

Restore ephemeral state after reconciliation.

Parameters:

state (dict) – State from get_ephemeral_state()

Return type:

None