> ## Documentation Index
> Fetch the complete documentation index at: https://luau.limerence.biz/llms.txt
> Use this file to discover all available pages before exploring further.

# Slider

> A slider for picking a number between min and max.

Also has everything from [ElementHandle](/ui/classes/element-handle).

A slider. Value is always kept inside `[min, max]`.

|                |                                                    |
| -------------- | -------------------------------------------------- |
| **Value type** | `number` (clamped to `[min, max]`)                 |
| **Created by** | [Section:AddSlider](/ui/classes/section#addslider) |

## Creation

```luau theme={null}
section:AddSlider(key, label, default, min, max, step, prefix?, suffix?)
```

<ParamField path="min" type="number" required>
  Lower bound.
</ParamField>

<ParamField path="max" type="number" required>
  Upper bound.
</ParamField>

<ParamField path="step" type="number" required>
  Increment for nudge and optional snap.
</ParamField>

<ParamField path="prefix" type="string?">
  Text shown before the number.
</ParamField>

<ParamField path="suffix" type="string?">
  Text shown after the number, e.g. `"%"`.
</ParamField>

***

## SetValue

```luau theme={null}
slider:SetValue(value: number, snapToStep: boolean?): ()
```

Set the value. Always clamped into range. Pass `true` for `snapToStep` to round to the nearest step.

***

## SetFromAlpha

```luau theme={null}
slider:SetFromAlpha(alpha: number): ()
```

Set using `0..1` instead of the real range. `0.5` is the middle.

***

## SetFromText

```luau theme={null}
slider:SetFromText(text: string): boolean
```

Try to set from a typed-in string. Returns `true` if the string was valid.

***

## GetAlpha

```luau theme={null}
slider:GetAlpha(): number
```

Current value as `0..1`.

***

## Nudge

```luau theme={null}
slider:Nudge(direction: number): ()
```

Bump the value up (`+1`) or down (`-1`) by a sensible amount.

***

## SetValueTextOverrides

```luau theme={null}
slider:SetValueTextOverrides(map: { [number]: string }): ()
```

Show custom text for specific numbers, e.g. `{ [0] = "Off" }` displays "Off" instead of `0`.

***

## Example

```luau theme={null}
local vol = section:AddSlider("volume", "Volume", 50, 0, 100, 1, nil, "%")
vol:SetValueTextOverrides({ [0] = "Mute" })
vol:SetFromAlpha(0.75)
-- Listen to the display string (not the raw number):
vol:Watch("formattedValue", function(s) print(s) end)
```
