Toddy.Iced.Widget.Slider (Toddy v0.3.0)

Copy Markdown View Source

Slider -- horizontal range input.

Props

  • range (list) -- [min, max] range as a two-element list. Default: [0, 100].
  • value (number) -- current slider value. Defaults to range minimum.
  • step (number) -- step increment.
  • width (length) -- slider width. Default: fill. See Toddy.Iced.Length.
  • default (number) -- default value (double-click resets to this).
  • height (number) -- slider track height in pixels.
  • shift_step (number) -- step increment when Shift is held.
  • circular_handle (boolean) -- use a circular handle instead of the default rectangular one. Default: false.
  • rail_color (hex color) -- color for the slider rail (both active and inactive portions).
  • rail_width (number) -- rail thickness in pixels.
  • style -- :default or StyleMap.t() for custom styling. See Toddy.Iced.StyleMap.
  • a11y (map) -- accessibility overrides. See Toddy.Iced.A11y.

Events

  • %Widget{type: :slide, id: id, value: value} -- emitted continuously while dragging.
  • %Widget{type: :slide_release, id: id, value: value} -- emitted when drag ends.

Summary

Functions

Sets accessibility annotations.

Converts this slider struct to a ui_node() map via the Toddy.Iced.Widget protocol.

Sets whether the slider handle is circular.

Sets the default value (double-click resets to this).

Sets the slider track height in pixels.

Creates a new slider struct with the given range, value, and optional keyword opts.

Sets the rail color.

Sets the rail width in pixels.

Sets the step increment when Shift is held.

Sets the step increment.

Sets the slider style.

Sets the slider width.

Applies keyword options to an existing slider struct.

Types

option()

@type option() ::
  {:step, number()}
  | {:shift_step, number()}
  | {:default, number()}
  | {:width, Toddy.Iced.Length.t()}
  | {:height, number()}
  | {:circular_handle, boolean()}
  | {:rail_color, Toddy.Iced.Color.input()}
  | {:rail_width, number()}
  | {:style, style()}
  | {:a11y, Toddy.Iced.A11y.t()}

style()

@type style() :: :default | Toddy.Iced.StyleMap.t()

t()

@type t() :: %Toddy.Iced.Widget.Slider{
  a11y: Toddy.Iced.A11y.t() | nil,
  circular_handle: boolean() | nil,
  default: number() | nil,
  height: number() | nil,
  id: String.t(),
  rail_color: Toddy.Iced.Color.t() | nil,
  rail_width: number() | nil,
  range: {number(), number()},
  shift_step: number() | nil,
  step: number() | nil,
  style: style() | nil,
  value: number(),
  width: Toddy.Iced.Length.t() | nil
}

Functions

a11y(slider, a11y)

@spec a11y(slider :: t(), a11y :: Toddy.Iced.A11y.t()) :: t()

Sets accessibility annotations.

build(slider)

@spec build(slider :: t()) :: Toddy.Iced.ui_node()

Converts this slider struct to a ui_node() map via the Toddy.Iced.Widget protocol.

circular_handle(slider, circular_handle)

@spec circular_handle(slider :: t(), circular_handle :: boolean()) :: t()

Sets whether the slider handle is circular.

default(slider, default)

@spec default(slider :: t(), default :: number()) :: t()

Sets the default value (double-click resets to this).

height(slider, height)

@spec height(slider :: t(), height :: number()) :: t()

Sets the slider track height in pixels.

new(id, range, value, opts \\ [])

@spec new(
  id :: String.t(),
  range :: {number(), number()},
  value :: number(),
  opts :: [option()]
) :: t()

Creates a new slider struct with the given range, value, and optional keyword opts.

rail_color(slider, rail_color)

@spec rail_color(slider :: t(), rail_color :: Toddy.Iced.Color.input()) :: t()

Sets the rail color.

rail_width(slider, rail_width)

@spec rail_width(slider :: t(), rail_width :: number()) :: t()

Sets the rail width in pixels.

shift_step(slider, shift_step)

@spec shift_step(slider :: t(), shift_step :: number()) :: t()

Sets the step increment when Shift is held.

step(slider, step)

@spec step(slider :: t(), step :: number()) :: t()

Sets the step increment.

style(slider, style)

@spec style(slider :: t(), style :: style()) :: t()

Sets the slider style.

width(slider, width)

@spec width(slider :: t(), width :: Toddy.Iced.Length.t()) :: t()

Sets the slider width.

with_options(slider, opts)

@spec with_options(slider :: t(), opts :: [option()]) :: t()

Applies keyword options to an existing slider struct.