tui-slider
A highly customizable and configurable slider widget for ratatui that puts you in full control of every visual aspect.
Whether you're building music players, audio mixers, settings panels, or progress indicators, tui-slider adapts to your needs with extensive customization options. Configure colors, symbols, orientations, alignments, borders, and behaviorโall through a clean, intuitive API. From minimalist progress bars to feature-rich interactive sliders, you decide exactly how your UI looks and feels.
โจ Features
- ๐๏ธ Horizontal and Vertical sliders - Support for both orientations
- ๐จ Border styles - Multiple border style options with customizable symbols
- ๐ฏ Title alignment - Left, center, and right title positioning
- ๐ Value alignment - Flexible value display positioning
- ๐ Vertical positioning - Label and value positioning for vertical sliders
- ๐จ Progress bars - Use as progress indicators without handles
- ๐ง Easy to use - Minimal configuration required
- ๐ State management - Built-in state for value tracking
- โก Lightweight - No complex dependencies
๐ฆ Installation
Add to your Cargo.toml:
[]
= "0.1"
= "0.28"
๐ Quick Start
use *;
use ;
๐ Examples
Horizontal Sliders

Basic horizontal slider:
use Color;
use ;
let state = new;
let slider = from_state
.orientation
.label
.show_value
.filled_symbol
.empty_symbol
.handle_symbol
.filled_color
.empty_color
.handle_color;
Horizontal Slider Styles
Using predefined horizontal slider styles:
use SliderStyle;
// Clean horizontal lines
let style = horizontal;
// Thick lines (default look)
let style = horizontal_thick;
// Bold blocks
let style = horizontal_blocks;
// Shaded gradient
let style = horizontal_gradient;
// Dots/circles
let style = horizontal_dots;
// Squares
let style = horizontal_squares;
// Double lines
let style = horizontal_double;
Vertical Sliders

Basic vertical slider:
use Color;
use ;
let state = new;
let slider = from_state
.orientation
.label
.show_value
.filled_symbol
.empty_symbol
.handle_symbol
.filled_color
.empty_color
.handle_color;
Vertical Slider Styles
Using predefined vertical slider styles:
use SliderStyle;
// Clean vertical lines
let style = vertical;
// Bold blocks
let style = vertical_blocks;
// Shaded gradient
let style = vertical_gradient;
// Dots/circles
let style = vertical_dots;
// Squares
let style = vertical_squares;
// Equalizer bars
let style = vertical_equalizer;
Border Styles

Multiple border styles available (Plain, Rounded, Double, Thick, Segmented):
use BorderStyle;
use ;
let block = default
.borders
.border_set
.title;
let slider = from_state.block;
Title Alignment

Control where titles appear on borders:
use ;
use ;
// Left-aligned title
let title = title_left;
let block = default.borders.title;
// Center-aligned title
let title = title_center;
let block = default.borders.title;
// Right-aligned title (use title_right_with_spacing if value is also right-aligned)
let title = title_right_with_spacing;
let block = default.borders.title;
Value Alignment

Control where values appear above/beside the slider (for horizontal sliders):
use Alignment;
// Left-aligned value
let slider = from_state
.show_value
.value_alignment;
// Center-aligned value
let slider = from_state
.show_value
.value_alignment;
// Right-aligned value (default)
let slider = from_state
.show_value
.value_alignment;
Vertical Slider Positioning
Control the positioning of labels and values in vertical sliders:
use ;
let state = new;
// Label at top, value at bottom center
let slider = from_state
.orientation
.label
.show_value
.vertical_label_position
.vertical_value_position
.vertical_value_alignment;
// Label at bottom, value at top left
let slider = from_state
.orientation
.label
.show_value
.vertical_label_position
.vertical_value_position
.vertical_value_alignment;
// Value at middle right
let slider = from_state
.orientation
.show_value
.vertical_value_position
.vertical_value_alignment;
Label Position Options:
VerticalLabelPosition::Top- Label at the top (default)VerticalLabelPosition::Bottom- Label at the bottom
Value Position Options:
VerticalValuePosition::Top- Value at the topVerticalValuePosition::Middle- Value at the middleVerticalValuePosition::Bottom- Value at the bottom (default)
Value Alignment Options:
VerticalValueAlignment::Left- Value aligned leftVerticalValueAlignment::Center- Value aligned center (default)VerticalValueAlignment::Right- Value aligned right
Recommended Symbols for Vertical Sliders:
use symbols;
// Clean vertical lines (default)
.filled_symbol // "โ"
.empty_symbol // "โ"
.handle_symbol // "โ"
// Or use predefined styles
use SliderStyle;
let style = vertical;
Recommended Symbols for Horizontal Sliders:
use symbols;
// Thick lines (default look)
.filled_symbol // "โ"
.empty_symbol // "โ"
.handle_symbol // "โ"
// Clean horizontal lines
.filled_symbol // "โ"
.empty_symbol // "โ"
.handle_symbol // "โ"
// Or use predefined styles
use SliderStyle;
let style = horizontal_thick;
Progress Bars

Use sliders as progress indicators by hiding the handle:
let slider = from_state
.filled_symbol
.empty_symbol
.show_handle // Hide handle for progress bar style
.show_value;
Custom Symbols
let slider = from_state
.filled_symbol
.empty_symbol
.handle_symbol
.filled_color
.show_handle;
Toggle Thumb/Handle Visibility
// Show the thumb indicator (default)
let slider = from_state
.show_thumb;
// Hide the thumb for a progress bar style
let slider = from_state
.show_thumb;
// show_handle() is an alias for show_thumb()
let slider = from_state
.show_handle;
๐ฎ Interactive Usage
use SliderState;
let mut state = new;
// Increase/decrease by a step
state.increase;
state.decrease;
// Set exact value
state.set_value;
// Get current value
let current = state.value;
// Get as percentage (0.0 to 1.0)
let percentage = state.percentage;
๐ฏ API Overview
Slider Widget
new(value, min, max)- Create a new sliderfrom_state(&state)- Create from a stateorientation(orientation)- Set horizontal or verticallabel(text)- Set label textshow_value(bool)- Show/hide value displayshow_handle(bool)- Show/hide handlefilled_symbol(symbol)- Set filled bar symbolempty_symbol(symbol)- Set empty bar symbolhandle_symbol(symbol)- Set handle symbolfilled_color(color)- Set filled bar colorempty_color(color)- Set empty bar colorhandle_color(color)- Set handle colorshow_handle(bool)- Show/hide thumb indicatorshow_thumb(bool)- Alias for show_handlevertical_label_position(position)- Set label position for vertical slidersvertical_value_position(position)- Set value position for vertical slidersvertical_value_alignment(alignment)- Set value alignment for vertical slidersblock(block)- Add border block
SliderState
new(value, min, max)- Create new statevalue()- Get current valueset_value(value)- Set valueincrease(step)- Increase by stepdecrease(step)- Decrease by stepmin()/max()- Get boundsset_min(min)/set_max(max)- Set boundspercentage()- Get value as percentage (0.0-1.0)set_percentage(percentage)- Set from percentage
๐จ Demos
Run the examples to see the sliders in action:
# Horizontal sliders with different styles
# Horizontal slider styles
# Vertical sliders (equalizer style)
# Border styles demonstration
# Title alignment examples
# Value alignment examples
# Vertical slider positioning examples
# Vertical slider styles
# Progress bar styles
# Custom slider configurations
# Toggle thumb/handle visibility
๐๏ธ Architecture
The library consists of three main components:
- Slider - The widget that renders the slider
- SliderState - Manages value, bounds, and state
- SliderOrientation - Horizontal or Vertical orientation
๐ ๏ธ Development
This project uses just as a command runner for common development tasks.
Quick Setup
Run the interactive setup script to install just and configure your environment:
This script will:
- Install
justcommand runner (if not already installed) - Create a new justfile if one doesn't exist (with common commands)
- Enhance existing justfile with missing commands (optional)
- Install optional tools like
git-clifffor changelog generation - Set up shell completion
- Create backups before modifying files
Manual Setup
If you prefer manual installation:
# Install just
# Install git-cliff (optional, for changelogs)
# View available commands
Common Commands
For a complete list of available commands, run just --list or see the justfile.
Justfile Patterns
This project follows the "fail early" pattern for version bumps and releases:
just bump <version>runs all checks (fmt, clippy, test) before bumpingjust release <version>depends onbump, ensuring quality before release- All destructive operations have quality gates
See Justfile Best Practices & Patterns for detailed documentation.
๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- Built with ratatui
- Inspired by various TUI music players and audio applications
๐ Changelog
See CHANGELOG.md for a list of changes.