# `Plushie.Widget.Slider`
[🔗](https://github.com/plushie-ui/plushie-elixir/blob/v0.7.2/lib/plushie/widget/slider.ex#L1)

Slider, horizontal range input.

## Props

| Name | Type | Default | Description |
|------|------|---------|-------------|
| `range` | `{number(), number()}` | required | `{min, max}` numeric range. |
| `value` | `number()` | required | Current slider value. |
| `step` | `number()` | `nil` | Step increment. |
| `shift_step` | `number()` | `nil` | Step increment when Shift is held. |
| `default` | `number()` | `nil` | Default value (double-click resets to this). |
| `width` | `:fill \| :shrink \| {:fill_portion, pos_integer()} \| number()` | `nil` | Slider width. Default: fill. |
| `height` | `number()` | `nil` | Slider track height in pixels. |
| `circular_handle` | `boolean()` | `nil` | Use a circular handle. Default: false. |
| `handle_radius` | `number()` | `nil` | Circular handle radius in pixels. Only used when circular_handle is true. |
| `rail_color` | `String.t()` | `nil` | Color for the slider rail. |
| `rail_width` | `number()` | `nil` | Rail thickness in pixels. |
| `style` | `:default
\| :primary
\| :secondary
\| :success
\| :danger
\| :warning
\| :dark
\| :weak
\| :rounded_box
\| term()` | `nil` | Named preset or custom `StyleMap`. |
| `label` | `String.t() \| atom()` | `nil` | Accessible label for the slider. |
| `event_rate` | `integer()` | `nil` | Max events per second for coalescable events. |
| `a11y` | `%Plushie.Type.A11y{} \| map() \| keyword()` | `%{role: :slider}` | Accessibility annotations. |

## Events

| Event | Type | Description |
|-------|------|-------------|
| `:slide` | `value: number()` | Emitted continuously while dragging. |
| `:slide_release` | `value: number()` | Emitted when drag ends. |

## Constructor

    Slider.new(id, range, value)
    Slider.new(id, range, value, opts)

# `option`

```elixir
@type option() ::
  ((((((((((({:step, number()} | {:shift_step, number()})
            | {:default, number()})
           | {:width,
              :fill | :shrink | {:fill_portion, pos_integer()} | number()})
          | {:height, number()})
         | {:circular_handle, boolean()})
        | {:handle_radius, number()})
       | {:rail_color, atom() | String.t() | map()})
      | {:rail_width, number()})
     | {:style,
        :default
        | :primary
        | :secondary
        | :success
        | :danger
        | :warning
        | :dark
        | :weak
        | :rounded_box
        | term()})
    | {:label, String.t() | atom()})
   | {:event_rate, integer()})
  | {:a11y,
     %Plushie.Type.A11y{
       active_descendant: term(),
       busy: term(),
       described_by: term(),
       description: term(),
       disabled: term(),
       error_message: term(),
       expanded: term(),
       has_popup: term(),
       hidden: term(),
       invalid: term(),
       label: term(),
       label_from: term(),
       labelled_by: term(),
       level: term(),
       live: term(),
       mnemonic: term(),
       modal: term(),
       orientation: term(),
       position_in_set: term(),
       radio_group: term(),
       read_only: term(),
       required: term(),
       role: term(),
       selected: term(),
       size_of_set: term(),
       toggled: term(),
       value: term()
     }
     | map()
     | keyword()}
```

# `t`

```elixir
@type t() :: %Plushie.Widget.Slider{
  a11y:
    (%Plushie.Type.A11y{
       active_descendant: term(),
       busy: term(),
       described_by: term(),
       description: term(),
       disabled: term(),
       error_message: term(),
       expanded: term(),
       has_popup: term(),
       hidden: term(),
       invalid: term(),
       label: term(),
       label_from: term(),
       labelled_by: term(),
       level: term(),
       live: term(),
       mnemonic: term(),
       modal: term(),
       orientation: term(),
       position_in_set: term(),
       radio_group: term(),
       read_only: term(),
       required: term(),
       role: term(),
       selected: term(),
       size_of_set: term(),
       toggled: term(),
       value: term()
     }
     | map()
     | keyword())
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  circular_handle:
    boolean()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  default:
    number()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  event_rate:
    integer()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  handle_radius:
    number()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  height:
    number()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  id: String.t(),
  label:
    (String.t() | atom())
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  rail_color:
    String.t()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  rail_width:
    number()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  range:
    {number(), number()}
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  shift_step:
    number()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  step:
    number()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  style:
    (:default
     | :primary
     | :secondary
     | :success
     | :danger
     | :warning
     | :dark
     | :weak
     | :rounded_box
     | term())
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  value:
    number()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  width:
    (:fill | :shrink | {:fill_portion, pos_integer()} | number())
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil
}
```

# `a11y`

```elixir
@spec a11y(
  widget :: t(),
  value ::
    (%Plushie.Type.A11y{
       active_descendant: term(),
       busy: term(),
       described_by: term(),
       description: term(),
       disabled: term(),
       error_message: term(),
       expanded: term(),
       has_popup: term(),
       hidden: term(),
       invalid: term(),
       label: term(),
       label_from: term(),
       labelled_by: term(),
       level: term(),
       live: term(),
       mnemonic: term(),
       modal: term(),
       orientation: term(),
       position_in_set: term(),
       radio_group: term(),
       read_only: term(),
       required: term(),
       role: term(),
       selected: term(),
       size_of_set: term(),
       toggled: term(),
       value: term()
     }
     | map()
     | keyword())
    | nil
) :: t()
```

Accessibility annotations.

Accepts `%Plushie.Type.A11y{} | map() | keyword()`.

# `build`

```elixir
@spec build(widget :: t()) :: Plushie.Widget.ui_node()
```

Converts this widget struct to a `ui_node()` map.

# `circular_handle`

```elixir
@spec circular_handle(widget :: t(), value :: boolean() | nil) :: t()
```

Use a circular handle. Default: false.

Accepts `boolean()`.

# `default`

```elixir
@spec default(widget :: t(), value :: number() | nil) :: t()
```

Default value (double-click resets to this).

Accepts `number()`.

# `event_rate`

```elixir
@spec event_rate(widget :: t(), value :: integer() | nil) :: t()
```

Max events per second for coalescable events.

Accepts `integer()`.

# `handle_radius`

```elixir
@spec handle_radius(widget :: t(), value :: number() | nil) :: t()
```

Circular handle radius in pixels. Only used when circular_handle is true.

Accepts `number()`.

# `height`

```elixir
@spec height(widget :: t(), value :: number() | nil) :: t()
```

Slider track height in pixels.

Accepts `number()`.

# `label`

```elixir
@spec label(widget :: t(), value :: (String.t() | atom()) | nil) :: t()
```

Accessible label for the slider.

Accepts `String.t() | atom()`.

# `new`

Creates a new widget struct with the given positional args and keyword options.

## Arguments

- `id` - unique widget identifier
- `range` - `{min, max}` numeric range.
- `value` - Current slider value.
- `opts` - keyword list of optional props

# `rail_color`

```elixir
@spec rail_color(widget :: t(), value :: (atom() | String.t() | map()) | nil) :: t()
```

Color for the slider rail.

Accepts `String.t()`.

# `rail_width`

```elixir
@spec rail_width(widget :: t(), value :: number() | nil) :: t()
```

Rail thickness in pixels.

Accepts `number()`.

# `range`

```elixir
@spec range(widget :: t(), value :: {number(), number()} | nil) :: t()
```

`{min, max}` numeric range.

Accepts `{number(), number()}`.

# `shift_step`

```elixir
@spec shift_step(widget :: t(), value :: number() | nil) :: t()
```

Step increment when Shift is held.

Accepts `number()`.

# `slider`
*macro* 

Creates a `:slider` widget.

Shorthand for `new/2`. Import this macro to use the widget name
directly in view functions:

    import Plushie.Widget.Slider, only: [slider: 2]

    slider("my-id", prop: value)

# `step`

```elixir
@spec step(widget :: t(), value :: number() | nil) :: t()
```

Step increment.

Accepts `number()`.

# `style`

```elixir
@spec style(
  widget :: t(),
  value ::
    (:default
     | :primary
     | :secondary
     | :success
     | :danger
     | :warning
     | :dark
     | :weak
     | :rounded_box
     | term())
    | nil
) :: t()
```

Named preset or custom `StyleMap`.

Accepts `:default
| :primary
| :secondary
| :success
| :danger
| :warning
| :dark
| :weak
| :rounded_box
| term()`.

# `value`

```elixir
@spec value(widget :: t(), value :: number() | nil) :: t()
```

Current slider value.

Accepts `number()`.

# `width`

```elixir
@spec width(
  widget :: t(),
  value :: (:fill | :shrink | {:fill_portion, pos_integer()} | number()) | nil
) ::
  t()
```

Slider width. Default: fill.

Accepts `:fill | :shrink | {:fill_portion, pos_integer()} | number()`.

# `with_options`

```elixir
@spec with_options(widget :: t(), opts :: [option()]) :: t()
```

Applies keyword options to an existing widget struct.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
