Slider
Description
The Slider component represents a range input control that allows users to select a numeric value within a specific range. It is ideal for cases where a user needs to adjust a value by moving a handle along a track. This component is part of the Tesserae UI component library and falls under the Components group.
Usage
To instantiate a Slider, use the static helper method from the Tesserae.UI class. You can configure its initial value, minimum value, maximum value, and step interval. The component supports both horizontal and vertical orientations and provides methods to enable or disable the slider.
Below is a simple code example that demonstrates how to create and use a Slider instance:
API reference
public sealed class Slider : ComponentBase<Slider, HTMLInputElement>A slider component.
- Namespace
- Tesserae
- Inheritance
- ComponentBase<Slider, HTMLInputElement> → Slider
Constructors
| Name | Description |
|---|---|
| Slider | Initializes a new instance of the Slider class. |
Properties
| Name | Description |
|---|---|
| Orientation | Gets or sets the orientation of the slider. |
| Value | Gets or sets the current value. |
| Min | Gets or sets the minimum value. |
| Max | Gets or sets the maximum value. |
| Step | Gets or sets the step size. |
| IsEnabled | Gets or sets whether the slider is enabled. |
public SliderOrientation Orientation { get ; set ; }Gets or sets the orientation of the slider.
Methods
| Name | Description |
|---|---|
| Render | Renders the component. |
| SetValue | Sets the value of the slider. |
| SetMin | Sets the minimum value of the slider. |
| SetMax | Sets the maximum value of the slider. |
| SetStep | Sets the step size of the slider. |
| Disabled | Sets whether the slider is disabled. |
| Horizontal | Sets the orientation to horizontal. |
| Vertical | Sets the orientation to vertical. |
public override HTMLElement Render()Renders the component.
Returns
The rendered HTML element.
public Slider SetValue(int val)Sets the value of the slider.
Parameters
- val
- The value.
Returns
The current instance.
public Slider SetMin(int min)Sets the minimum value of the slider.
Parameters
- min
- The minimum value.
Returns
The current instance.
public Slider SetMax(int max)Sets the maximum value of the slider.
Parameters
- max
- The maximum value.
Returns
The current instance.
public Slider SetStep(int step)Sets the step size of the slider.
Parameters
- step
- The step size.
Returns
The current instance.
public Slider Disabled(bool value = true)Sets whether the slider is disabled.
Parameters
- value
- Whether it's disabled.
Returns
The current instance.
public Slider Horizontal()Sets the orientation to horizontal.
Returns
The current instance.
Samples
Basic Slider Usage
This sample demonstrates how to create a basic horizontal slider configured with a minimum value of 0, a maximum value of 100, a default value of 0, and a step value of 1. The sample also shows how to attach an input event to handle user interactions.
Vertical Slider with Custom Range
This sample demonstrates setting up a vertical slider along with custom minimum, maximum, and step values. The slider orientation is changed to vertical using the Vertical() method.