PromptPlus

PromptPlus # PromptPlus ## **Slider** [![NuGet](https://img.shields.io/badge/NuGet-PromptPlus-blue)](https://www.nuget.org/packages/PromptPlus) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![.NET](https://img.shields.io/badge/.NET-8%20%7C%209%20%7C%2010-512BD4)](https://dotnet.microsoft.com/)

← Back to HomeNext: Slider — Methods →


Pick a numeric value by moving a bar between a minimum and a maximum. The user nudges the value with the arrow keys and confirms with Enter.

The Slider control is the natural way to collect a bounded number — volume, brightness, a timeout in seconds, a priority, a percentage. Instead of typing digits, the user slides a visual bar between the limits you define. It supports custom ranges, decimal precision, small and large steps, per-value coloring, gradients, a vertical layout, and persistent history — all through a single fluent chain.

📊 Just need to display a value without asking for input? Use the read-only Slider widget instead — it renders the same bar but does not wait for the user.


On this page

Sub-page What you will find
Index (this page) What it is, when to use it, a first working example, the method map
Methods Every fluent method — signature, parameters, defaults, and a snippet
Operations Keyboard, stepping, ranges, gradients, history, and edge cases
Styles The SliderStyles regions and how to recolor them

When to use it

Use Slider when… Consider instead…
You need a bounded numeric value chosen by feel
The user should pick from a short, discrete list Select
You need free numeric entry, currency, or a fixed pattern MaskEdit family
You only need to display a value, not collect one Slider widget

Minimal example

using PromptPlusLibrary;

var result = PromptPlus.Controls
    .Slider("Select value")
    .Run();

if (!result.IsAborted)
    PromptPlus.Console.WriteLine($"Value: {result.Content}");

💡 The value is nullable. On abort .Content is null — always check IsAborted first.


A more complete example

using PromptPlusLibrary;

var temperature = PromptPlus.Controls
    .Slider("Target temperature", "Custom range -50..50")
    .Range(-50, 50)          // lower / upper limit
    .FractionalDigits(1)          // one decimal place
    .Step(0.5)                // arrow keys move by 0.5
    .LargeStep(5)             // Page Up / Page Down move by 5
    .Default(0)               // start centered
    .Run();

if (!temperature.IsAborted)
    PromptPlus.Console.WriteLine($"Temperature: {temperature.Content}");

This combines the four things you most often tune together: a custom range (Range), precision (FractionalDigits), the small and large step sizes (Step, LargeStep), and a starting value (Default). See Operations for how stepping behaves at runtime.


Method map

Grouped by purpose. Full signatures and examples are on the Methods page.

Purpose Methods
Range & precision Range, Width, FractionalDigits, Culture
Starting value Default
Step increments Step, LargeStep
Bar appearance & layout BarType, ChangeColor, ChangeGradient, HideElements, Layout
Dynamic description ChangeDescription, ChangeDescriptionAsync
History EnableHistory
Appearance & behavior Styles, Options
Run Run

Return value

Slider returns ResultPrompt<double?>.

Member Meaning
.Content The confirmed value (null if aborted)
.IsAborted true when the user pressed Esc / the abort key
var (value, aborted) = PromptPlus.Controls.Slider("Value").Run();
if (!aborted) PromptPlus.Console.WriteLine($"{value}");

See also