Skip to main content

Overview

HuxSlider is a customizable slider component with smooth animations, consistent styling, and automatic theme adaptation. It provides a clean, modern interface for selecting numeric values within a range while maintaining accessibility standards.

Basic Usage

Basic Slider

Slider with Label

Slider with Value Display

Slider with Divisions

Disabled Slider

Properties

Core Properties

  • value - Current slider value (double)
  • onChanged - Callback triggered when value changes (null for disabled)
  • min - Minimum value (default: 0.0)
  • max - Maximum value (default: 100.0)

Display Properties

  • label - Optional label displayed above the slider
  • showValue - Whether to display the current value next to the label
  • divisions - Number of discrete divisions (null for continuous)

Styling Properties

  • size - Slider size variant (small, medium, large)
  • activeColor - Custom active color (uses primary color by default)
  • isDisabled - Whether the slider is disabled

Size Variants

Small Slider

  • Track Height: 2px
  • Thumb Size: 14px × 14px
  • Overlay Size: 28px × 28px
  • Tick Size: 2px

Medium Slider ⭐ Default

  • Track Height: 3px
  • Thumb Size: 18px × 18px
  • Overlay Size: 36px × 36px
  • Tick Size: 3px

Large Slider

  • Track Height: 4px
  • Thumb Size: 22px × 22px
  • Overlay Size: 44px × 44px
  • Tick Size: 4px

Styling & Colors

Slider Colors

  • Active Track: HuxTokens.primary(context) (or custom activeColor)
  • Inactive Track: HuxTokens.surfaceSecondary(context)
  • Thumb: HuxTokens.primary(context) (or custom activeColor)
  • Overlay: Primary color with 10% opacity
  • Tick Marks: HuxTokens.primary(context) (when divisions are used)

Disabled State Colors

  • Active Track (Disabled): HuxTokens.borderSecondary(context)
  • Inactive Track (Disabled): HuxTokens.surfaceSecondary(context) with 50% opacity
  • Thumb (Disabled): HuxTokens.surfaceSecondary(context)
  • Text (Disabled): HuxTokens.textDisabled(context)

Custom Colors

You can customize the slider’s active color:

Advanced Examples

Volume Control

Rating Slider

Price Range Filter

Form Integration

Accessibility

HuxSlider follows Flutter’s accessibility guidelines:
  • Supports keyboard navigation
  • Provides semantic labels for screen readers
  • Maintains proper touch target sizes (minimum 44px × 44px)
  • Uses theme-aware colors that meet WCAG contrast requirements

Best Practices

  1. Use Labels: Always provide a label to make the slider’s purpose clear
  2. Show Values: Use showValue: true when the exact value is important
  3. Use Divisions: Set divisions when you need discrete values (e.g., ratings, steps)
  4. Provide Feedback: Consider showing additional feedback when the value changes (e.g., updating a preview)
  5. Range Selection: For range selection, use two sliders or consider a RangeSlider component

API Reference

HuxSlider Properties

HuxSliderSize Enum

  • HuxSliderSize.small - Small slider for compact layouts
  • HuxSliderSize.medium - Medium slider for standard use (default)
  • HuxSliderSize.large - Large slider for emphasis