slider-rs 0.0.2

🎚️ A highly customizable slider component for WASM frameworks like Yew, Dioxus, and Leptos.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
#![doc = include_str!("../DIOXUS.md")]

use crate::common::{Color, Cursor, Height, Orientation, Size, Width};
use dioxus::prelude::*;
use std::rc::Rc;
use uuid::Uuid;
use web_sys::HtmlInputElement;

#[derive(Props, PartialEq, Clone)]
pub struct LabelProps {
    #[props(default)]
    label: &'static str,
    #[props(default = "font-size: 14px; margin-bottom: 8px; text-align: center;")]
    label_style: &'static str,
    #[props(default = "slider-label")]
    label_class: &'static str,
}

#[component]
fn Label(props: LabelProps) -> Element {
    rsx! {
        label {
            class: "{props.label_class}",
            style: "{props.label_style}",
            "{props.label}"
        }
    }
}

#[derive(Props, PartialEq, Clone)]
pub struct StepsProps {
    #[props(default = 0.0)]
    min: f64,
    #[props(default = 10.0)]
    max: f64,
    #[props(default = 1.0)]
    step: f64,
    #[props(
        default = "width: 100%; display: flex; justify-content: space-between; margin-top: 8px; font-size: 10px;"
    )]
    steps_style: &'static str,
    #[props(default)]
    orientation: Orientation,
}

#[component]
fn Steps(props: StepsProps) -> Element {
    let count = ((props.max - props.min) / props.step).floor() as usize;

    let steps = (0..=count).map(|i| {
        let val = props.min + (i as f64 * props.step);
        let style = if props.orientation.is_vertical() {
            "margin: 4px 0; writing-mode: vertical-rl; text-align: center;"
        } else {
            "text-align: center;"
        };
        rsx! {
            span {
                style: "{style}",
                "{val:.0}"
            }
        }
    });

    let container_style = if props.orientation.is_vertical() {
        "display: flex; flex-direction: column; align-items: center; height: 100%; font-size: 10px;"
    } else {
        props.steps_style
    };

    rsx! {
        div {
            style: "{container_style}",
            {steps}
        }
    }
}

#[derive(Props, PartialEq, Clone)]
pub struct OutputProps {
    #[props(default)]
    value_display: String,
    #[props(default = "font-size: 12px; margin-top: 8px; text-align: center;")]
    output_style: &'static str,
    #[props(default = "slider-output")]
    output_class: &'static str,
    #[props(
        default = "background-color: #333; color: #fff; padding: 4px 8px; border-radius: 4px; font-size: 12px; position: absolute; transform: translate(-50%, -120%); display: block; pointer-events: none;"
    )]
    tooltip_style: &'static str,
    #[props(default = false)]
    show_tooltip: bool,
    #[props(default)]
    tooltip_left: String,
}

#[component]
fn Output(props: OutputProps) -> Element {
    let style = format!("{} left: {};", props.tooltip_style, props.tooltip_left);
    rsx! {
        output {
            class: "{props.output_class}",
            style: "{props.output_style}",
            aria_live: "polite",
            "{props.value_display}"
        }
        if props.show_tooltip {
            div {
                class: "{props.output_class}",
                style: "{style}",
                "{props.value_display}"
            }
        }
    }
}

#[derive(Props, PartialEq, Clone)]
pub struct TicksProps {
    #[props(default)]
    id: String,
    #[props(default = 0.0)]
    min: f64,
    #[props(default = 10.0)]
    max: f64,
    #[props(default = 1.0)]
    step: f64,
}

#[component]
fn Ticks(props: TicksProps) -> Element {
    let mut current = props.min;
    let mut options = vec![];

    while current <= props.max {
        options.push(rsx! {
            option {
                value: "{current}"
            }
        });
        current += props.step;
    }

    rsx! {
        datalist {
            id: "{props.id}",
            {options.into_iter()}
        }
    }
}

#[derive(Props, PartialEq, Clone)]
pub struct InputProps {
    #[props(default)]
    input_ref: Signal<Option<Rc<MountedData>>>,
    #[props(default = 0.0)]
    min: f64,
    #[props(default = 10.0)]
    max: f64,
    #[props(default = 1.0)]
    step: f64,
    #[props(default = 0.0)]
    value: f64,
    #[props(default)]
    orientation: Orientation,
    #[props(default)]
    size: Size,
    #[props(default)]
    width: Width,
    #[props(default)]
    height: Height,
    #[props(default)]
    color: Color,
    #[props(default)]
    cursor_style: Cursor,
    #[props(default = false)]
    disabled: bool,
    #[props(default)]
    on_input: Callback<FormEvent>,
    #[props(default)]
    on_focus: Callback<FocusEvent>,
    #[props(default)]
    on_blur: Callback<FocusEvent>,
    #[props(default)]
    aria_label: Option<&'static str>,
    #[props(default)]
    aria_describedby: Option<&'static str>,
    #[props(default)]
    datalist_id: Option<String>,
    #[props(default = "slider-input")]
    input_class: &'static str,
    #[props(default = "border-radius: 8px; appearance: none; outline: none;")]
    input_style: &'static str,
    #[props(default = true)]
    use_gradient: bool,
    #[props(default)]
    custom_thumb_css: Option<&'static str>,
    #[props(default)]
    custom_thumb_html: Option<Element>,
    #[props(default = 1.0)]
    keyboard_step: f64,
    #[props(default = false)]
    rtl_fill: bool,
}

#[component]
fn Input(props: InputProps) -> Element {
    let mut props = props.clone();
    let value_percent = ((props.value - props.min) / (props.max - props.min)) * 100.0;
    let fill_color = props.color.to_color_code();
    let gradient = if props.use_gradient {
        if props.orientation.is_vertical() {
            if props.rtl_fill {
                format!(
                    "background: linear-gradient(to top, {} 0%, {} {:.2}%, #ccc {:.2}%, #ccc 100%);",
                    fill_color, fill_color, value_percent, value_percent
                )
            } else {
                format!(
                    "background: linear-gradient(to bottom, {} 0%, {} {:.2}%, #ccc {:.2}%, #ccc 100%);",
                    fill_color, fill_color, value_percent, value_percent
                )
            }
        } else if props.rtl_fill {
            format!(
                "background: linear-gradient(to left, {} 0%, {} {:.2}%, #ccc {:.2}%, #ccc 100%);",
                fill_color, fill_color, value_percent, value_percent
            )
        } else {
            format!(
                "background: linear-gradient(to right, {} 0%, {} {:.2}%, #ccc {:.2}%, #ccc 100%);",
                fill_color, fill_color, value_percent, value_percent
            )
        }
    } else {
        format!("background: {};", fill_color)
    };

    let base_style = format!(
        "cursor: pointer; transition: background 0.3s; {} {} {} {} {} {}",
        props.input_style,
        props.width.to_style(),
        props.height.to_style(),
        gradient,
        props.orientation.to_style(),
        props.size.to_style(),
    );

    let on_key_down = Callback::new({
        move |e: Event<KeyboardData>| {
            let data = e.data;
            if let Some(el) = (props.input_ref)() {
                if let Some(input) = el.downcast::<HtmlInputElement>() {
                    let current = input.value().parse::<f64>().unwrap_or(0.0);
                    let new_val = match data.key() {
                        Key::ArrowLeft | Key::ArrowDown => current - props.keyboard_step,
                        Key::ArrowRight | Key::ArrowUp => current + props.keyboard_step,
                        _ => current,
                    }
                    .clamp(props.min, props.max);

                    input.set_value(&new_val.to_string());

                    if let Ok(event) = web_sys::Event::new("input") {
                        let _ = input.dispatch_event(&event);
                    }
                }
            }
        }
    });

    rsx! {
        input {
            onmounted: move |cx| props.input_ref.set(Some(cx.data())),
            r#type: "range",
            class: "{props.input_class}",
            min: "{props.min}",
            max: "{props.max}",
            step: if props.step == 0.0 { "any".to_string() } else { props.step.to_string() },
            value: "{props.value}",
            list: props.datalist_id.clone().unwrap_or_default(),
            oninput: move |e| props.on_input.call(e),
            onfocus: move |e| props.on_focus.call(e),
            onblur: move |e| props.on_blur.call(e),
            onkeydown: on_key_down,
            disabled: props.disabled,
            aria_label: props.aria_label.unwrap_or("Slider"),
            aria_describedby: props.aria_describedby.unwrap_or("Slider description"),
            style: "{base_style}",
        }
        if let Some(custom_html) = props.custom_thumb_html.clone() {
            {custom_html}
        }
    }
}

/// Props for the `Slider` component.
///
/// These props configure the behavior, appearance, and accessibility of a slider input component
/// supporting both single and double (range) sliders.
///
/// # Features
/// - Single or double slider modes.
/// - Vertical or horizontal orientation.
/// - Customizable appearance with CSS styles and classes.
/// - Tooltip, value display, and step indicators.
/// - Full accessibility support (ARIA attributes, keyboard steps).
#[derive(PartialEq, Clone, Props)]
pub struct SliderProps {
    /// Label text displayed above the slider.
    #[props(default)]
    pub label: &'static str,

    /// Minimum value for the slider.
    #[props(default = 0.0)]
    pub min: f64,

    /// Maximum value for the slider.
    #[props(default = 10.0)]
    pub max: f64,

    /// Increment step size.
    #[props(default = 1.0)]
    pub step: f64,

    /// Current value for a single slider mode.
    #[props(default)]
    pub value: Option<f64>,

    /// Current range values (start, end) for double slider mode.
    #[props(default)]
    pub range: Option<(f64, f64)>,

    /// Whether to enable double slider mode (range selector).
    #[props(default = false)]
    pub double: bool,

    /// Slider orientation: horizontal or vertical.
    #[props(default)]
    pub orientation: Orientation,

    /// Size variant for styling the slider track and thumb.
    #[props(default)]
    pub size: Size,

    /// Color variant for styling the slider.
    #[props(default)]
    pub color: Color,

    /// Cursor style when hovering over the slider.
    #[props(default)]
    pub cursor_style: Cursor,

    /// Whether to show the current value as an output.
    #[props(default = false)]
    pub show_value: bool,

    /// Whether to show step ticks along the slider track.
    #[props(default = false)]
    pub show_steps: bool,

    /// Whether to show tooltip above the thumb on hover.
    #[props(default = false)]
    pub show_tooltip: bool,

    /// Whether to disable interaction with the slider.
    #[props(default = false)]
    pub disabled: bool,

    /// Callback triggered when the slider value changes.
    #[props(default)]
    pub on_change: Callback<f64>,

    /// Callback triggered when the slider range changes (double mode).
    #[props(default)]
    pub on_change_range: Callback<(f64, f64)>,

    /// Callback triggered when the slider gains focus.
    #[props(default)]
    pub on_focus: Callback<()>,

    /// Callback triggered when the slider loses focus.
    #[props(default)]
    pub on_blur: Callback<()>,

    /// ARIA label for accessibility.
    #[props(default)]
    pub aria_label: Option<&'static str>,

    /// ARIA describedby attribute for accessibility.
    #[props(default)]
    pub aria_describedby: Option<&'static str>,

    /// CSS class for the container wrapping the slider.
    #[props(default = "slider-container")]
    pub container_class: &'static str,

    /// Inline style for the container wrapping the slider.
    #[props(
        default = "display: flex; flex-direction: column; align-items: center; margin: 20px; position: relative;"
    )]
    pub container_style: &'static str,

    /// CSS class for the slider label.
    #[props(default = "slider-label")]
    pub label_class: &'static str,

    /// Inline style for the slider label.
    #[props(default = "font-size: 14px; margin-bottom: 8px;")]
    pub label_style: &'static str,

    /// CSS class for the slider input element.
    #[props(default = "slider-input")]
    pub input_class: &'static str,

    /// Inline style for the slider input element.
    #[props(default = "border-radius: 8px; appearance: none; outline: none;")]
    pub input_style: &'static str,

    /// CSS class for the value/output display.
    #[props(default = "slider-output")]
    pub output_class: &'static str,

    /// Inline style for the value/output display.
    #[props(default = "font-size: 12px; margin-top: 8px;")]
    pub output_style: &'static str,

    /// Inline style for the tooltip element.
    #[props(
        default = "background-color: #333; color: #fff; padding: 4px 8px; border-radius: 4px; font-size: 12px; display: none;"
    )]
    pub tooltip_style: &'static str,

    /// Inline style for the steps indicator below the slider track.
    #[props(
        default = "width: 100%; display: flex; justify-content: space-between; margin-top: 8px; font-size: 10px;"
    )]
    pub steps_style: &'static str,

    /// Custom width for the slider track.
    #[props(default)]
    pub slider_width: Width,

    /// Custom height for the slider track.
    #[props(default)]
    pub slider_height: Height,

    /// Optional custom CSS for the slider thumb.
    #[props(default)]
    pub custom_thumb_css: Option<&'static str>,

    /// Optional custom HTML content for the slider thumb.
    #[props(default)]
    pub custom_thumb_html: Option<Element>,

    /// Keyboard step increment for arrow key adjustments.
    #[props(default = 1.0)]
    pub keyboard_step: f64,

    /// Optional icon element displayed before the slider.
    #[props(default)]
    pub icon_start: Option<Element>,

    /// Optional icon element displayed after the slider.
    #[props(default)]
    pub icon_end: Option<Element>,
}

/// Slider Component
///
/// A Dioxus range slider component with extensive customization and accessibility support.
///
/// # Features
/// - Single value or double range mode (TODO).
/// - Horizontal and vertical orientations.
/// - Customizable track, thumb, tooltip, and step indicators.
/// - Full ARIA support for accessibility.
/// - Keyboard controls with adjustable increments.
///
/// # Examples
///
/// ## Single Value Slider
/// ```rust
/// use dioxus::prelude::*;
/// use slider_rs::dioxus::Slider;
///
/// fn app() -> Element {
///     rsx! {
///         Slider {
///             label: "Volume",
///             min: 0.0,
///             max: 100.0,
///             step: 1.0,
///             show_value: true,
///             on_change: Callback::new(move |v| log::info!("Value: {}", v)),
///         }
///     }
/// }
/// ```
///
/// ## Double Range Slider
/// ```rust
/// use dioxus::prelude::*;
/// use slider_rs::dioxus::Slider;
///
/// fn app() -> Element {
///     rsx! {
///         Slider {
///             label: "Select Range",
///             min: 0.0,
///             max: 100.0,
///             step: 5.0,
///             range: Some((20.0, 80.0)),
///             double: true,
///             show_value: true,
///             on_change_range: Callback::new(move |(start, end)| log::info!("Range: {} - {}", start, end)),
///         }
///     }
/// }
/// ```
///
/// # Notes
/// - Subcomponents include: `Label`, `Input`, `Ticks`, `Output`, `Steps`.
/// - Double slider mode renders two overlapping input elements.
/// - Styling is fully customizable via `*_style` and `*_class` props.
///
/// # Accessibility
/// - Supports ARIA roles, orientation, and description attributes.
/// - Keyboard navigation with configurable step increments.
///
/// # See Also
/// - [MDN <input type="range"> Element](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/range)
#[component]
pub fn Slider(props: SliderProps) -> Element {
    let mut val1 = use_signal(|| props.range.unwrap_or((props.min, props.max)).0);
    let mut val2 = use_signal(|| props.range.unwrap_or((props.min, props.max)).1);

    let input_ref1: Signal<Option<Rc<MountedData>>> = use_signal(|| None);
    let input_ref2: Signal<Option<Rc<MountedData>>> = use_signal(|| None);

    let list_id = use_memo(|| format!("slider-list-{}", Uuid::new_v4()));

    let update_range = {
        Callback::new(move |_| {
            props.on_change_range.call((val1(), val2()));
            props.on_change.call(val1());
        })
    };

    let on_input1 = {
        Callback::new(move |e: FormEvent| {
            if let Ok(input) = e.value().parse::<f64>() {
                val1.set(input);
                update_range.call(());
                props.on_change.call(input);
            }
        })
    };

    let on_input2 = {
        Callback::new(move |e: FormEvent| {
            if let Ok(input) = e.value().parse::<f64>() {
                val2.set(input);
                update_range.call(());
                props.on_change.call(input);
            }
        })
    };

    let on_focus_cb = { Callback::new(move |_e: FocusEvent| props.on_focus.call(())) };

    let on_blur_cb = { Callback::new(move |_e: FocusEvent| props.on_blur.call(())) };

    let (input_style1, input_style2): (&'static str, &'static str) = if props.double {
        let flipped_style = Box::leak(Box::new(format!(
            "{}; transform: rotate(0deg); direction: rtl; z-index: 3; position: relative; flex: 1;",
            props.input_style
        )));
        let normal_style = Box::leak(Box::new(format!(
            "{}; z-index: 2; position: relative; flex: 1;",
            props.input_style
        )));
        (flipped_style, normal_style)
    } else {
        (props.input_style, props.input_style)
    };

    let orientation_attr = if props.orientation.is_vertical() {
        "vertical"
    } else {
        "horizontal"
    };

    let steps_component = if props.show_steps {
        rsx! {
            Ticks { id: list_id().clone(), min: props.min, max: props.max, step: props.step }
            Steps {
                min: props.min,
                max: props.max,
                step: props.step,
                steps_style: props.steps_style,
                orientation: props.orientation.clone()
            }
        }
    } else {
        rsx! {}
    };

    let double_input = if props.double {
        rsx! {
            Input {
                input_ref: input_ref2,
                min: props.min,
                max: props.max,
                step: props.step,
                value: val2(),
                orientation: props.orientation.clone(),
                disabled: props.disabled,
                size: props.size.clone(),
                color: props.color.clone(),
                cursor_style: props.cursor_style.clone(),
                input_class: props.input_class,
                input_style: input_style2,
                on_input: on_input2,
                on_focus: on_focus_cb,
                on_blur: on_blur_cb,
                datalist_id: Some(list_id().clone()),
                aria_label: props.aria_label,
                aria_describedby: props.aria_describedby,
                width: props.slider_width.clone(),
                height: props.slider_height.clone(),
                custom_thumb_css: props.custom_thumb_css,
                custom_thumb_html: props.custom_thumb_html.clone(),
                keyboard_step: props.keyboard_step,
            }
        }
    } else {
        rsx! {}
    };

    let value_display = if props.show_value {
        rsx! {
            Output {
                value_display: format!("{:.1}", val1()),
                output_class: props.output_class,
                output_style: props.output_style,
                tooltip_style: props.tooltip_style,
                show_tooltip: props.show_tooltip,
                tooltip_left: format!("{:.2}%", ((val1() - props.min) / (props.max - props.min)) * 100.0),
            }
        }
    } else {
        rsx! {}
    };

    let input_group = if props.orientation.is_vertical() {
        rsx! {
            div {
                style: "display: flex; flex-direction: row; align-items: flex-start;",
                {props.icon_start.unwrap_or(rsx!{})}
                Input {
                    input_ref: input_ref1,
                    min: props.min,
                    max: props.max,
                    step: props.step,
                    value: val1(),
                    orientation: props.orientation.clone(),
                    disabled: props.disabled,
                    size: props.size,
                    color: props.color,
                    cursor_style: props.cursor_style,
                    input_class: props.input_class,
                    input_style: input_style1,
                    on_input: on_input1,
                    on_focus: on_focus_cb,
                    on_blur: on_blur_cb,
                    datalist_id: Some(list_id()),
                    aria_label: props.aria_label,
                    aria_describedby: props.aria_describedby,
                    width: props.slider_width,
                    height: props.slider_height,
                    custom_thumb_css: props.custom_thumb_css,
                    custom_thumb_html: props.custom_thumb_html,
                    keyboard_step: props.keyboard_step,
                }
                {double_input}
                {props.icon_end.unwrap_or(rsx!{})}
                {steps_component}
            }
        }
    } else if props.double {
        rsx! {
            div {
                style: "position: relative; width: 100%; display: flex; align-items: center;",
                {props.icon_start.unwrap_or(rsx!{})}
                Input {
                    input_ref: input_ref1,
                    min: props.min,
                    max: props.max,
                    step: props.step,
                    value: val1(),
                    orientation: props.orientation.clone(),
                    disabled: props.disabled,
                    size: props.size,
                    color: props.color.clone(),
                    cursor_style: props.cursor_style.clone(),
                    input_class: props.input_class,
                    input_style: input_style1,
                    on_input: on_input1,
                    on_focus: on_focus_cb,
                    on_blur: on_blur_cb,
                    datalist_id: Some(list_id().clone()),
                    aria_label: props.aria_label,
                    aria_describedby: props.aria_describedby,
                    width: props.slider_width.clone(),
                    height: props.slider_height.clone(),
                    custom_thumb_css: props.custom_thumb_css,
                    custom_thumb_html: props.custom_thumb_html.clone(),
                    keyboard_step: props.keyboard_step,
                }
                {double_input}
                {props.icon_end.clone().unwrap_or(rsx!{})}
            }
        }
    } else {
        rsx! {
            div {
                style: "display: flex; align-items: center; width: 100%;",
                {props.icon_start.clone().unwrap_or(rsx!{})}
                Input {
                    input_ref: input_ref1,
                    min: props.min,
                    max: props.max,
                    step: props.step,
                    value: val1(),
                    orientation: props.orientation.clone(),
                    disabled: props.disabled,
                    size: props.size.clone(),
                    color: props.color.clone(),
                    cursor_style: props.cursor_style.clone(),
                    input_class: props.input_class,
                    input_style: input_style1,
                    on_input: on_input1,
                    on_focus: on_focus_cb,
                    on_blur: on_blur_cb,
                    datalist_id: Some(list_id().clone()),
                    aria_label: props.aria_label,
                    aria_describedby: props.aria_describedby,
                    width: props.slider_width.clone(),
                    height: props.slider_height.clone(),
                    custom_thumb_css: props.custom_thumb_css,
                    custom_thumb_html: props.custom_thumb_html.clone(),
                    keyboard_step: props.keyboard_step,
                }
                {props.icon_end.clone().unwrap_or(rsx!{})}
            }
        }
    };

    let horizontal_steps = if props.show_steps && !props.orientation.is_vertical() {
        rsx! {
            Steps {
                min: props.min,
                max: props.max,
                step: props.step,
                steps_style: props.steps_style,
                orientation: props.orientation.clone()
            }
        }
    } else {
        rsx! {}
    };

    rsx! {
        div {
            class: "{props.container_class}",
            style: "{props.container_style}",
            role: "group",
            aria_orientation: "{orientation_attr}",
            aria_disabled: "{props.disabled}",
            Label {
                label: props.label,
                label_class: props.label_class,
                label_style: props.label_style
            }
            {input_group}
            Ticks { id: list_id().clone(), min: props.min, max: props.max, step: props.step }
            {value_display}
            {horizontal_steps}
        }
    }
}