Interactive forms with slider controls for selecting numeric values visually. Sliders are perfect for ratings, ranges, budgets, and any value where users benefit from seeing their selection on a scale.
Every code snippet below is fully editable! Feel free to modify the code, experiment with different values, and see your changes reflected instantly in the live preview on the right.
Use the play button to run different snippet, or the refresh button to restore the original example.
Let's start with an empty form function. This is where we'll build our slider-based form step by step.
Let's add a simple slider for a rating from 0 to 10. Sliders provide an intuitive way for users to select values within a range.
addSlider() and require min and max properties. The current value is displayed in a clickable box - users can click it to type a precise value directly! Now let's add a budget slider with a custom range and step increment. The step property controls how much the value changes with each slider movement.
step to control the increment size. For a budget slider with $500 increments, set step: 500. The defaultValue sets the initial position. Add a unit label to make the value more meaningful. The unit is displayed next to the current value, making it clear what the number represents.
unit property adds a label after the value (e.g., "1500 sq ft"). Common units include "sq ft", "hours", "%", "kg", "miles", etc. Combine a slider with a computed value to create dynamic calculations. As the user moves the slider, the calculated result updates automatically.
computedValue on other fields to calculate results based on slider values. Access the slider value with form.slider('id')?.value(). Let's build a complete service quote calculator with multiple sliders. Each slider affects the final quote calculation.
Excellent! You've mastered slider fields and learned how to build interactive calculators. Ready to explore more advanced form features?
Continue to Computed Values TutorialOther learning paths: